Draw string sample android

2010-11-27  来源:本站原创  分类:Mobile  人气:177 

In game development, we can not all use the images to display, often need to draw the string, such as the development of a RPG game, there are a lot of conversations, then if all sure not to use images to display. Here we take a look if the string in the Canvas to draw it on canvas.
android drawText provided a series of methods to draw the string, before the need to set the brush to draw the string object, including a string of size, color and other properties. FontMetrics to plan to use the font properties, you can getFontMetrics method to get the system font of the relevant content. The following look at a lot of text wrap, flip and examples of how the string operation, operating results see below

Draw string sample android

When we press the arrow keys will change to the next line on the arrow keys to change the font to the font on the line. Below we have listed commonly used in string processing methods:
setTextSize: Set the size of the string
setARGB: Set the color (ARGB)
getTextWidths: get width of string
setFlags (Paint.ANTI_ALIAS_FLAG): anti-aliasing.

For this example, the code is not longer posted here, and have the time and not interested can download the source code of.

  • Draw string sample android 2010-11-27

    In game development, we can not all use the images to display, often need to draw the string, such as the development of a RPG game, there are a lot of conversations, then if all sure not to use images to display. Here we take a look if the string in

  • Android DrawText draw string 2010-06-11

    package com.Aina.Android; import java.util.Vector; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Paint.FontMetrics; import android.view.KeyEvent; public class TextUtil { private

  • Play music sample android 2010-12-16

    This example is a small example of music is relatively simple, you need to download 2. Mp3 at the end of the song, and then edge into the SD card to test, you can see the effects. Operating results are as follows main.xml <?xml version="1.0"

  • Play video sample android 2010-12-17

    Because Android platform consists of Google own package, designed to provide the Java Dalvik in the algorithm efficiency can not be with the C / C + + or ARM ASM par, in the description or transplant some of the local language decoder look powerless,

  • Android Framework (II) Person Sample with restserver 2011-05-30

    Android Framework (II) Person Sample with restserver 1. Base settings I only use the spring rest template part, so my pom.xml will be like this: <Project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns: xsi = "http://www.w3.org/2001/XM

  • android获取string.xml的值 2013-01-08

    为什么需要把应用中出现的文字单独存放在string.xml文件中呢? 一:是为了国际化,当需要国际化时,只需要再提供一个string.xml文件,把里面的汉子信息都修改为对应的语言(如,English),再运行程序时,android操作系统会根据用户手机的语言环境和国家来自动选择相应的string.xml文件,这时手机界面就会显示出英文.这样做国际化非常的方便. 二:为了减少应用的体积,降低数据的冗余.假设在应用中要使用"我们一直在努力"这段文字1000次,如果在每次使用时直接写上这几

  • android NinePatch Tutorial - Creating a beautiful background image 2010-12-15

    In this tutorial, will detail NinePatch OPhone image format introduced, and how to use images to create and OPhone NinePatch style of uniform application system. In the following tutorial OPhone system used as demonstration Button control. OPhone sys

  • Xiang Jie Android's Activity component 2010-03-29

    http://www.ibm.com/developerworks/cn/opensource/os-cn-android-actvt/index.html?ca=drs-cn-0122 Activity of the life cycle And J2ME, MIDlet, as in android in, Activity of the life cycle to the system under unified management. The difference is that wit

  • Android drawing study summary (3) - Drawable 2010-06-21

    Android SDK provides a powerful class Drawable, Drawable this abstract class in the end what it means and how to use? Drawable is a very abstract concept of a simple example program to study it, understand it. Look at a simple example, using the Draw

  • Analysis of the AIDL Android interface 2010-07-20

    1.4.2 elaborate on Stub category code The Stub class that is the output from the aidl.exe; also is calInterface.java inside. CalInterface.java hereby repeat code listed below: /*---- CalInterface.java ----*/ / * * This file is auto-generated. DO NOT

  • Android drawing study summary (5) - Paint 2010-07-27

    Android drawing study summary (5) - Paint Previous drawing study concluded a series of Android , we were learning a Bitmap , Drawable , Aniamtion , in addition to the drawing elements, the development of applications using the most or the String (str

  • Implementation based on Android English Electronic Dictionary 2010-07-31

    English dictionary is the frequent use of mobile phone applications. Therefore, in this paper to discuss how Android will combine to achieve an Android version of the English dictionary. There are many ways to achieve the English dictionary. In this

  • android list view component ListView Xiangjie 2010-09-03

    ListView android development in a more common component of the form it displayed a list of specific content, and adaptive to the length of the data shows. Find time to make use of the ListView do organize, and write a small example, as shown below. L

  • Use AIDL (Android Interface Description Language) design and use of remote interface 2010-09-28

    Directory 1 Use AIDL (AndRoid Interface Description Language) design and use of remote interface 1.1 IPC implementation using AIDL 1.1.1 Creating a AIDL file 1.1.2 implement the interface Public interface to the client 1.1.3 1.1.4 the value of using

  • Junit unit testing to achieve android 2010-10-12

    Thought the android to achieve unit testing, should be a very simple thing, the result was to spend some effort, mainly in the configuration file, and the test environment to spend a lot of time, more complicated than expected, but also Nothing profo

  • Writing an Android Sync Provider: Part 1 2010-10-27

    One of the highlights of the Android 2.0 SDK is that you can write custom sync providers to integrate with the system contacts, calendars, etc. The only problem is that there's very little documentation on how it all fits together. And worse, if you

  • (Rpm) Detailed Android's Activity component 2010-10-29

    While writing this article, feel is the most basic of Activity, but things are still many details, but said very comprehensive, so turn around and share the hope that helps ~ ================================ ================ Text start =============

  • Android allows you to write the Launcher as the first boot the system, and it is the only Launcher (reprint) 2010-11-17

    If you want to customize an Android system, you want to use your own Launcher (Home) decide their own interface to replace the Android Home, and do not want the user to install the Launcher to back replace your Launcher. We can modify the Framework t

  • android drawing geometry 2010-11-27

    Previous articles are some of the rectangle inside a painting, today to see how the android phone number on the screen to draw geometric shapes, such as triangles, polygons, ellipses, circles, squares and so on. And set of hollow, solid. Let us first

  • Android HTTP request to visit 2010-12-05

    This chapter, will be relatively simple, yet due to the current progress of the need for network interface planning and design, so there is no time to set up the server environment, joint debugging. But based on past project experience, so long as th