EventThe button cannot be placed in the linearlayout. Otherwise, when you click the entire linearlayout, you cannot execute the click command in the area occupied by the button. (Maybe you can solve it by setting focusable)
18. The gettext method of edittext does not return null.(Therefore, gettext is called without mull judgment ).
19. textview:
You can use Android: textstyle = "bold" in the XML file to set English to bold,
However, you cannot set Chinese to bold,
The method to set Ch
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 recalculated based on the Image Height.Target. right = (int) (textHeight * (bitmap. getWidth ()/(float) bitmap. getHeight ()));// St
, R.DRAWABLE.IMG3, R.DRAWABLE.IMG4, r.drawable.img5}; Private arraylist4. Create a small Origin custom object CircleShapePackage Com.world.hello.circleindicator;import Android.graphics.paint;import Android.graphics.drawable.shapedrawable;import android.graphics.drawable.shapes.shape;/** * Small Dot class * Created by Chengguo on 2016/6/1. */public class CircleShape {//Set default value private float x = 0; Private float y = 0; Private shapedrawable shape; private paint paint;
the android SDK provides a powerful class drawable. What does the abstract class drawable represent and how to use it? Drawable is a very abstract concept. It is learned and understood by a simple Program . Let's take a look at a simple example and draw a picture using the sub-class shapedrawable of drawable, as shown below: public class testview extends view { private shapedrawable mdrawable; Public testview (context) { super (context); int x = 10; int y = 10; int width = 300; int Height
Google found that there are several ways to do this in Android, but after actual testing, we found that the following method is the most accurate
Rect bounds =NewRect (); string text= "Hello World"; Textpaint paint; Paint=Findviewbyid (R. Id. hello_world). getpaint (); paint. gettextbounds (text,0, Text. Length (), bounds );IntWidth = bounds. Width ();
Paint pfont =NewPaint (); rect=NewRect (); pfont. gettextbounds ("Beans", 0, 1, Rect); log. V (T
Listview selects the last item by default.Android: stackFromBottom = "true" android: transcriptMode = "alwaysScroll"Android Chinese boldAndroid: FIG = "#000000"Android: shadowDx = "0.2" android: shadowDy = "0.0" android: shadowRadius = "0.2"Android: textStyle = "bold" can be used in xml files to set English to bold, but Chinese cannot be set to bold,The method for setting Chinese characters to bold is TextView TV = (TextView) findViewById (R. id. TextView01 );TextPaint tp = TV.
Facebook open-source Shimmer, a loading effect tool, enables the font to shine as follows:
The link here is ghost (no object-c, ghost ZR), so I searched Shimmer android. Someone actually did it. Here, https://github.com/romainpiel/shimmer-android. The following is
VcnBtq + release/Y1sajrM/Cw + a + zcC01/release + release = "brush: java;"> public class MyTextView extends TextView {private LinearGradient mLinearGradient; private Matrix mGradientMatrix; private Paint mPaint; private int mViewWidt
Summary of 16 small experiences developed by Android and 16 articles developed by Android
Summary of 16 small experiences in Android development. I hope it will be helpful to anyone who is engaged in Android development.
1. The getTextSize returned value in TextView is in pixels (px,
The unit of setTextSize () is sp.
Therefore, an error occurs when the returned value is directly set. The solution is to use another form of setTextSize (). You can specify the unit:
setTextSize(intunit,intsize)
(context, attrs ); } @ Override Public void onDraw (Canvas canvas ){ Super. onDraw (canvas ); DrawText (canvas, 0xffff0000 ); Super. onDraw (canvas ); } // Note: only single-line word processing is performed here. Private void drawText (Canvas canvas, int bg ){ Paint paint = getPaint (); // Obtain textview text String text = String. valueOf (getText ()); // Obtain the left margin of the first line of text Float startX = getLayout (). getLineLeft (0 )
line.The following code is copied directly from the project on Git.
The code is as follows
Copy Code
Package Com.example.shimmer; Import Android.content.Context;Import Android.graphics.Canvas;Import android.graphics.LinearGradient;Import Android.graphics.Matrix;Import Android.graphics.Paint;Import Android.graphics.Shader;Import Android.util.AttributeSet;Import Android.widget.TextView; public class Mytextview extends TextView { Private LinearGradient mlineargradient;P
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.