Basic attributes
- layout_width, the height of the component
- match_parent width takes the width outside it (parent container)
- wrap_content automatically allocates its width based on the content inside the control
- Write the value directly (not recommended)
- layout_height, the height of the component
- id, the ID of the component
- text, text content
- textColor sets the font color ( eight digits, hexadecimal, two digits together, transparency, RGB )
- textStyle, set the font style, three options, normal (no effect), bold (bold), italic (italic)
- textSize, font size, unit is generally sp
- background, the background of the component
- Gravity, sets the alignment direction of the content in the component, TextView is text, ImageView is picture, etc.
Text and color values in XML must be written in res and standardized
This is to adapt to different types and styles. It only requires a few XMLs and does not require repeated development.
TextView with shadow
android:shadowColor, sets the shadow color, needs to be used with shadowRadius
android: shadowRadius, set the blur level of the shadow. If it is set to 0.1, it will become the font color. It is recommended to use 3.0
android: shadowDx, sets the offset of the shadow in the horizontal direction, that is, the abscissa of the start of the horizontal shadow
android:shadowDy, same as above
TextView to achieve marquee effect
android: singleLine, set the content to be displayed in a single line, which has been deprecated. Use lines="1", but it can be used with singleLine, but lines cannot run.
android: focusable, whether it can get focus
android: focusableInTouchMode, used to control whether focus can be done in touch mode
android: ellipsize, where to omit text, use marquee
android:marqueeRepeatLimit, the number of times the letter animation is repeated
How to make him run
- Set processing method, clickable
- Use a custom view, inherit from the TextView class, implement the first three construction methods, call isfocus, and return True. Change XML to custom class
- Use <requestFocus/> inside a tag
The main idea is: words have multiple columns or lines, the ability to obtain focus, whether focus is provided within the program or interactively, and three methods of providing focus
<com.example.android003.Mypamadeng
android:layout_width="match_parent"
android:layout_height="103dp"
android:gravity="center_vertical"
android:shadowColor="@color/red"
android:shadowDx="10"
android:shadowDy="10"
android:shadowRadius="3"
android:text="@string/jieke"
android:textColor="@color/blue"
android:textSize="@android:dimen/app_icon_size"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true">
</com.example.android003.Mypamadeng>