安卓个人学习------UI布局组件学习与整理简析

来源:互联网 发布:创维电视直播软件 编辑:程序博客网 时间:2024/06/06 03:50

TextView

属性:下面的为安卓官方源码

XML AttributesAttribute NameRelated MethodDescriptionandroid:autoLinksetAutoLinkMask(int)Controls whether links such as urls and email addresses are automatically found and converted to clickable links. android:autoTextsetKeyListener(KeyListener)If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. android:bufferTypesetText(CharSequence,TextView.BufferType)Determines the minimum type that getText() will return. android:capitalizesetKeyListener(KeyListener)If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. android:cursorVisiblesetCursorVisible(boolean)Makes the cursor visible (the default) or invisible. android:digitssetKeyListener(KeyListener)If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. android:drawableBottomsetCompoundDrawablesWithIntrinsicBounds(int,int,int,int)The drawable to be drawn below the text. android:drawableLeftsetCompoundDrawablesWithIntrinsicBounds(int,int,int,int)The drawable to be drawn to the left of the text. android:drawablePaddingsetCompoundDrawablePadding(int)The padding between the drawables and the text. android:drawableRightsetCompoundDrawablesWithIntrinsicBounds(int,int,int,int)The drawable to be drawn to the right of the text. android:drawableTopsetCompoundDrawablesWithIntrinsicBounds(int,int,int,int)The drawable to be drawn above the text. android:editable If set, specifies that this TextView has an input method. android:editorExtrassetInputExtras(int)Reference to an <input-extras> XML resource containing additional data to supply to an input method, which is private to the implementation of the input method. android:ellipsizesetEllipsize(TextUtils.TruncateAt)If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. android:emssetEms(int)Makes the TextView be exactly this many ems wide. android:freezesTextsetFreezesText(boolean)If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. android:gravitysetGravity(int)Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view. android:heightsetHeight(int)Makes the TextView be exactly this many pixels tall. android:hintsetHint(int)Hint text to display when the text is empty. android:imeActionIdsetImeActionLabel(CharSequence,int)Supply a value for EditorInfo.actionId used when an input method is connected to the text view. android:imeActionLabelsetImeActionLabel(CharSequence,int)Supply a value for EditorInfo.actionLabel used when an input method is connected to the text view. android:imeOptionssetImeOptions(int)Additional features you can enable in an IME associated with an editor to improve the integration with your application. android:includeFontPaddingsetIncludeFontPadding(boolean)Leave enough room for ascenders and descenders instead of using the font ascent and descent strictly. android:inputMethodsetKeyListener(KeyListener)If set, specifies that this TextView should use the specified input method (specified by fully-qualified class name). android:inputTypesetRawInputType(int)The type of data being placed in a text field, used to help an input method decide how to let the user enter text. android:lineSpacingExtrasetLineSpacing(float,float)Extra spacing between lines of text. android:lineSpacingMultipliersetLineSpacing(float,float)Extra spacing between lines of text, as a multiplier. android:linessetLines(int)Makes the TextView be exactly this many lines tall. android:linksClickablesetLinksClickable(boolean)If set to false, keeps the movement method from being set to the link movement method even if autoLink causes links to be found. android:marqueeRepeatLimitsetMarqueeRepeatLimit(int)The number of times to repeat the marquee animation. android:maxEmssetMaxEms(int)Makes the TextView be at most this many ems wide. android:maxHeightsetMaxHeight(int)Makes the TextView be at most this many pixels tall. android:maxLengthsetFilters(InputFilter)Set an input filter to constrain the text length to the specified number. android:maxLinessetMaxLines(int)Makes the TextView be at most this many lines tall. android:maxWidthsetMaxWidth(int)Makes the TextView be at most this many pixels wide. android:minEmssetMinEms(int)Makes the TextView be at least this many ems wide. android:minHeightsetMinHeight(int)Makes the TextView be at least this many pixels tall. android:minLinessetMinLines(int)Makes the TextView be at least this many lines tall. android:minWidthsetMinWidth(int)Makes the TextView be at least this many pixels wide. android:numericsetKeyListener(KeyListener)If set, specifies that this TextView has a numeric input method. android:passwordsetTransformationMethod(TransformationMethod)Whether the characters of the field are displayed as password dots instead of themselves. android:phoneNumbersetKeyListener(KeyListener)If set, specifies that this TextView has a phone number input method. android:privateImeOptionssetPrivateImeOptions(String)An addition content type description to supply to the input method attached to the text view, which is private to the implementation of the input method. android:scrollHorizontallysetHorizontallyScrolling(boolean)Whether the text is allowed to be wider than the view (and therefore can be scrolled horizontally). android:selectAllOnFocussetSelectAllOnFocus(boolean)If the text is selectable, select it all when the view takes focus instead of moving the cursor to the start or end. android:shadowColorsetShadowLayer(float,float,float,int)Place a shadow of the specified color behind the text. android:shadowDxsetShadowLayer(float,float,float,int)Horizontal offset of the shadow. android:shadowDysetShadowLayer(float,float,float,int)Vertical offset of the shadow. android:shadowRadiussetShadowLayer(float,float,float,int)Radius of the shadow. android:singleLinesetTransformationMethod(TransformationMethod)Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. android:textsetText(CharSequence,TextView.BufferType)Text to display. android:textAllCapssetAllCaps(boolean)Present the text in ALL CAPS. android:textAppearance Base text color, typeface, size, and style. android:textColorsetTextColor(int)Text color. android:textColorHighlightsetHighlightColor(int)Color of the text selection highlight. android:textColorHintsetHintTextColor(int)Color of the hint text. android:textColorLinksetLinkTextColor(int)Text color for links. android:textIsSelectableisTextSelectable()Indicates that the content of a non-editable text can be selected. android:textScaleXsetTextScaleX(float)Sets the horizontal scaling factor for the text. android:textSizesetTextSize(int,float)Size of the text. android:textStylesetTypeface(Typeface)Style (bold, italic, bolditalic) for the text. android:typefacesetTypeface(Typeface)Typeface (normal, sans, serif, monospace) for the text. android:widthsetWidth(int)Makes the TextView be exactly this many pixels wide. 

请看下面的例子:

string.xml布局代码:

<?xml version="1.0" encoding="utf-8"?><resources>    <string name="hello">Hello World, TextViewTestActivity!</string>    <string name="app_name">TextViewTest</string>    <string name="webUrl">宋鹤贤 blog.csdn.net/jimjarry</string>    <string name="email">宋鹤贤的邮箱:songhexian@sina.com</string>    <string name="phoneNumber">电话号码: 18931260000</string>    <string name="mapUrl">620 Eighth Avenue New York, NY 10018 \n    </string>    <string name="autoAll">       宋鹤贤:blog.csdn.net/jimjarry 宋鹤贤的邮箱:songhexian@sina.com 电话号码: 18931260000        </string></resources>


Java代码:

package cn.class3g.activity;import android.app.Activity;import android.os.Bundle;import android.text.Html;import android.widget.TextView;public class TextViewTestActivity extends Activity {    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.border_tv);        //        TextView tv = (TextView) this.findViewById(R.id.tvHtml);//        //        String htmlStr = "<font size='30' color='#00FF22'>我爱</font> 学<b>习</b>安卓" +//        "<br><a href='blog.csdn.net/jimjarry'>宋鹤贤</a>";//        //        tv.setText(Html.fromHtml(htmlStr));    }}






原创粉丝点击