); // set the font2. Use android: textStyle = "bold" in the xml file to set English to bold, but not Chinese to bold,The method to set Chinese to bold is:TextView TV = (TextView) findViewById (R. id. TextView01 );TV. getPaint (). setFakeBoldText (true); // Chinese imitation "bold" -- use TextPaint imitation "bold" to set setFakeBoldText to true.Hi.baidu.com/...4.htmlHi.baidu.com/...9.htmlHow to set the font in TextView in android
Changing the Font Typ
();Src. bottom = bitmap. getHeight ();Int textHeight = (int) getTextSize ();Target. left = 0;// Calculate the ordinate value of the image copied to the target region. Because the text content of the TextView component is not// Draw from the top. Therefore, you need to recalculate the ordinate of the drawn image.Target. top = (int) (getMeasuredHeight ()-getTextSize ()/2) + 1;Target. bottom = target. top + textHeight;// To ensure that the image is not deformed, the width of the image needs to be
. TruncateAt. valueOf ("END "));
TV. setEllipsize (TextUtils. TruncateAt. valueOf ("START "));
TV. setEllipsize (TextUtils. TruncateAt. valueOf ("MIDDLE "));
TV. setEllipsize (TextUtils. TruncateAt. valueOf ("MARQUEE "));
TV. setSingleLine (true );
26: edittext cursor in XML: Android: pidding = "10dp", you can move the cursor back a bit and set the cursor behind the font in the Code: titleView. setSelection (titleView. getText (). length (); () indicates the content length of the input box.
27:
. MIRROR, Shader. tileMode. MIRROR); // create LinearGradient and set the gradient Color array mLinearGradient = new LinearGradient (0, 0,100,100, new int [] {Color. RED, Color. GREEN, Color. BLUE, Color. WHITE}, null, Shader. tileMode. REPEAT );/ /Hybrid rendering. Here BitmapShader and LinearGradient are used for hybrid rendering. Try other functions ~ MComposeShader = new ComposeShader (mBitmapShader, mLinearGradient, PorterDuff. mode. DARKEN); // ring gradient rendering mRadialGradient = new
From: http://www.r-base.net/archives/442
In Android UI development, if you use XML to configure layout, we can easily implement compatibility issues with different resolutions (using dip units ). however, if you cannot use XML to configure layout in a game, it will be a lot of trouble if we are compatible with different resolutions. some coordinate calculations can also change the units of dip to pixels. when I was developing a hamster game, I found that the text was hard to calculate the width.
(intWintHintOLDW,intOLDH) { Super. Onsizechanged (W, H, OLDW, OLDH); if(mviewwidth==0) {//Initially initialized to 0, so it will enter this if judgment statementMviewwidth=getmeasuredwidth ();//gets the current width if(mviewwidth>0) {Mpaint=getpaint ();//Gets the Paint object for the current drawing TextView /** Set a lineargradient gradient renderer * The 12th parameter is the starting point for setting the gradient, where the
;Urldrawable.setbounds (0, 0, bitmap.getwidth (), Bitmap.getheight ());Textview.settext (Textview.gettext ())//Without this sentence does not show the picture, for unknown reasons}@Overridepublic void onbitmapfailed (drawable errordrawable) {}@Overridepublic void Onprepareload (drawable placeholderdrawable) {}});return urldrawable;}}
Urldrawable class:
/*** Created by the Administrator on 2016/6/28 0028.*/public class Urldrawable extends Bitmapdrawable {Public Bitmap Bitmap;@Overridepublic voi
r = This.getcontext (). Getresources ();Ii. How to get drawing objects in resources
Data Packet package:android.graphics.drawable
Main class: Drawable
Drawable is a virtual class, how to paint, you need to specifically analyze the drawable subclass, such as: bitmapdrawable
The main interfaces are as follows:
Bitmapdrawable ()Bitmapdrawable (Bitmap Bitmap)Bitmapdrawable (String filepath)Bitmapdrawable (InputStream is)void Draw (Canvas Canvas)Final Bitmap Getbitmap ()Final Paint
,
mPaint2);
Canvas.save ();
Canvas.translate (0);
Super.ondraw (canvas);
Canvas.restore ();
We drew two rectangles with unequal widths, and the canvas translated 10 units. The custom controls that are drawn here are:
This example, very simple, maybe we have to inherit the original control or the meaning of the words, our hundred feet head further. Make a slightly more complex point. Custom textview--with blinking text TextView.
We analyze the realization of the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.