ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
##TextView与EditText详解 TextView  顾名思义:就是在界面上呈现文本信息,主要用于显示,没有特殊的事件响应。然而EditText与TexView非常相似,EditText就是多了一个可以让用户输入内容的编辑框功能。     大家可以把EditText看作是编辑内容的那个框,TextView是用于显示文本内容的框。  其实就是这么简单。然而EditText是TextView的子类。接下来就是TextView和EditText的全部XML属性如下。不过在此之前,要先解释一个属性margin和padding   margin和padding如下图所示: ![](https://box.kancloud.cn/2016-04-26_571f42c854c94.jpg) margin是子容器相距父容器边框的距离,而padding是子容器中的内容距离子容器边框的距离。那么margin_left和margin_right、padding_left和padding_right之类的属性就很好理解了。比如margin_left就是子容器距离父容器左边这一边的偏移距离,其他什么right、top、bottom都是这个意思。 1.  TextView和EditText的xml属性。 好了理解了这两个属性之后,我们来看看官网对TextView的属性介绍:  经常用的用红色显示 <table class="jd-sumtable " id="lattrs"><tbody><tr><th colspan="12">XML Attributes</th></tr><tr><td><nobr><em>Attribute Name(xml)</em></nobr></td><td><nobr><em>Related Method(方法)</em></nobr></td><td><nobr><em>Description(说明)</em></nobr></td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:autoLink">android:autoLink</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setAutoLinkMask%28int%29">setAutoLinkMask(int)</a></td><td width="100%" class="jd-descrcol"><div><span style="color:#ff0000">是否将符合指定格式的文本转化为可点击的超链接形式,比如(网址,电话等)</span></div><div><br/></div></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:autoText">android:autoText</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setKeyListener%28android.text.method.KeyListener%29">setKeyListener(KeyListener)</a></td><td width="100%" class="jd-descrcol">是否将URL、E-mail地址等链接自动转换为可单击的链接</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:breakStrategy">android:breakStrategy</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setBreakStrategy%28int%29">setBreakStrategy(int)</a></td><td width="100%" class="jd-descrcol">Break strategy (control over paragraph layout). </td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:bufferType">android:bufferType</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setText%28java.lang.CharSequence,%20android.widget.TextView.BufferType%29">setText(CharSequence,TextView.BufferType)</a></td><td width="100%" class="jd-descrcol">Determines the minimum type that getText() will return. </td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:capitalize">android:capitalize</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setKeyListener%28android.text.method.KeyListener%29">setKeyListener(KeyListener)</a></td><td width="100%" class="jd-descrcol"><div><span style="color:#ff0000">控制是否将用户输入的文本转化为大写字母,支持一下属性值:</span></div><div><span style="color:#ff0000"><br/></span></div><div><span style="color:#ff0000">   none:不转换</span></div><div><span style="color:#ff0000">   sentences:每个句子的首字母大写</span></div><div><span style="color:#ff0000">  words:每个单词的首字母大写</span></div><div><span style="color:#ff0000">  characters:每个字母都大写</span></div><div><br/></div></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:cursorVisible">android:cursorVisible</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCursorVisible%28boolean%29">setCursorVisible(boolean)</a></td><td width="100%" class="jd-descrcol">设置该文本框的光标是否可见</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:digits">android:digits</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setKeyListener%28android.text.method.KeyListener%29">setKeyListener(KeyListener)</a></td><td width="100%" class="jd-descrcol">如果设置为true,则该文本框对应一个数字输入方法,并且只接受那些合法字符</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:drawableBottom">android:drawableBottom</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCompoundDrawablesWithIntrinsicBounds%28int,%20int,%20int,%20int%29">setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)</a></td><td width="100%" class="jd-descrcol">在文本框底部绘制指定图像</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:drawableEnd">android:drawableEnd</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCompoundDrawablesRelativeWithIntrinsicBounds%28int,%20int,%20int,%20int%29">setCompoundDrawablesRelativeWithIntrinsicBounds(int,int,int,int)</a></td><td width="100%" class="jd-descrcol">在文本框的结尾处绘制指定图像</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:drawableLeft">android:drawableLeft</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCompoundDrawablesWithIntrinsicBounds%28int,%20int,%20int,%20int%29">setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)</a></td><td width="100%" class="jd-descrcol">在文本框的左边绘制指定的图像</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:drawablePadding">android:drawablePadding</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCompoundDrawablePadding%28int%29">setCompoundDrawablePadding(int)</a></td><td width="100%" class="jd-descrcol">设置文本框内文本与图像之间的间距</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:drawableRight">android:drawableRight</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCompoundDrawablesWithIntrinsicBounds%28int,%20int,%20int,%20int%29">setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)</a></td><td width="100%" class="jd-descrcol">在文本框的右边绘制指定的图像</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:drawableStart">android:drawableStart</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCompoundDrawablesRelativeWithIntrinsicBounds%28int,%20int,%20int,%20int%29">setCompoundDrawablesRelativeWithIntrinsicBounds(int,int,int,int)</a></td><td width="100%" class="jd-descrcol">在文本框的开始处绘制绘制指定的图像</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:drawableTint">android:drawableTint</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCompoundDrawableTintList%28android.content.res.ColorStateList%29">setCompoundDrawableTintList(ColorStateList)</a></td><td width="100%" class="jd-descrcol">为文本的图像指定颜色</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:drawableTintMode">android:drawableTintMode</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCompoundDrawableTintMode%28android.graphics.PorterDuff.Mode%29">setCompoundDrawableTintMode(PorterDuff.Mode)</a></td><td width="100%" class="jd-descrcol">混合模式用于调节文本图像的颜色,如(颜色渐变之类的)</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:drawableTop">android:drawableTop</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setCompoundDrawablesWithIntrinsicBounds%28int,%20int,%20int,%20int%29">setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)</a></td><td width="100%" class="jd-descrcol">在文本框的顶部绘制指定的图像</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:editable">android:editable</a></td><td class="jd-linkcol"> </td><td width="100%" class="jd-descrcol">设置文本框是否允许编辑</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:editorExtras">android:editorExtras</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setInputExtras%28int%29">setInputExtras(int)</a></td><td width="100%" class="jd-descrcol"><code>参考一个包含额外的<a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/R.styleable.html#InputExtras">&lt;input-extras&gt;</a></code> XML资源用给输入法,这是私人对输入方法的执行。</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:elegantTextHeight">android:elegantTextHeight</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setElegantTextHeight%28boolean%29">setElegantTextHeight(boolean)</a></td><td width="100%" class="jd-descrcol">优雅的文字高度,特别是对于不那么复杂的文字文字。</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:ellipsize">android:ellipsize</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setEllipsize%28android.text.TextUtils.TruncateAt%29">setEllipsize(TextUtils.TruncateAt)</a></td><td width="100%" class="jd-descrcol"><div><span style="color:#ff0000">设置显示文本超过了TextView的长度时如何处理文本内容,有以下属性值:</span></div><div><span style="color:rgb(255,0,0)"> </span></div><div><span style="color:rgb(255,0,0)">   none:不做任何处理</span></div><div><span style="color:rgb(255,0,0)">   start:在文本开始处截断,并显示省略号</span></div><div><span style="color:rgb(255,0,0)">   middle:在文本中间处截断,并显示省略号</span></div><div><span style="color:rgb(255,0,0)">   end:在文本结尾处截断,并显示省略号</span></div><div><span style="color:rgb(255,0,0)">   marquee:使用marquee滚动动画显示文本( 跑马灯效果 )</span></div><div><br/></div></td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:ems">android:ems</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setEms%28int%29">setEms(int)</a></td><td width="100%" class="jd-descrcol">设置该组件的宽度,以em为单位</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:fontFamily">android:fontFamily</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setTypeface%28android.graphics.Typeface%29">setTypeface(Typeface)</a></td><td width="100%" class="jd-descrcol">设置文本框内文本的字体</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:fontFeatureSettings">android:fontFeatureSettings</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setFontFeatureSettings%28java.lang.String%29">setFontFeatureSettings(String)</a></td><td width="100%" class="jd-descrcol"><div class="trans-prompt"><p class="prompt-wrap"/></div><div class="original-mean-output"/><div class="trans-right clearfix"><div class="trans-output-wrap"><div class="output-container"><div class="output-wrap"><div class="output-mod ordinary-wrap"><div class="output-bd" dir="ltr" style="padding-bottom:0px"><p class="ordinary-output source-output" dir="ltr">Font feature settings.</p><p class="ordinary-output target-output">设置文本字体特征</p></div></div></div></div></div></div></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:freezesText">android:freezesText</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setFreezesText%28boolean%29">setFreezesText(boolean)</a></td><td width="100%" class="jd-descrcol">如果设置,文本视图将包括目前的完整文本在冰冻的冰除了元数据,如当前光标位置。</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:gravity">android:gravity</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setGravity%28int%29">setGravity(int)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本框内文本的对齐方式,一般center用的多</span></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:height">android:height</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setHeight%28int%29">setHeight(int)</a></td><td width="100%" class="jd-descrcol">设置文本框的高度,以px为单位</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:hint">android:hint</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setHint%28int%29">setHint(int)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置当文本框内的内容为空时,文本框内默认显示的提示文本</span></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:hyphenationFrequency">android:hyphenationFrequency</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setHyphenationFrequency%28int%29">setHyphenationFrequency(int)</a></td><td width="100%" class="jd-descrcol">自动断字频率。</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:imeActionId">android:imeActionId</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setImeActionLabel%28java.lang.CharSequence,%20int%29">setImeActionLabel(CharSequence,int)</a></td><td width="100%" class="jd-descrcol"><code>当文本框指定特定的输入法时,为输入法指定额外的<a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/view/inputmethod/EditorInfo.html#actionId">EditorInfo.actionId</a></code> 值</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:imeActionLabel">android:imeActionLabel</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setImeActionLabel%28java.lang.CharSequence,%20int%29">setImeActionLabel(CharSequence,int)</a></td><td width="100%" class="jd-descrcol"><code><span style="font-family:Courier New">当文本框指定特定的输入法时,为输入法指定额外的</span><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/view/inputmethod/EditorInfo.html#actionId"/><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/view/inputmethod/EditorInfo.html#actionLabel">EditorInfo.actionLabel值</a></code> </td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:imeOptions">android:imeOptions</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setImeOptions%28int%29">setImeOptions(int)</a></td><td width="100%" class="jd-descrcol"><span style="font-family:Courier New">当文本框指定特定的输入法时,为输入法指定额外的选项</span></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:includeFontPadding">android:includeFontPadding</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setIncludeFontPadding%28boolean%29">setIncludeFontPadding(boolean)</a></td><td width="100%" class="jd-descrcol">设置是否为字体保留足够多的空间,默认值为  true</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:inputMethod">android:inputMethod</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setKeyListener%28android.text.method.KeyListener%29">setKeyListener(KeyListener)</a></td><td width="100%" class="jd-descrcol">为文本框指定特定的输入法,该属性值为输入法的权限定类名</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:inputType">android:inputType</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setRawInputType%28int%29">setRawInputType(int)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本字中的数据类型(比如手机号  密码之类的)</span></td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:letterSpacing">android:letterSpacing</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setLetterSpacing%28float%29">setLetterSpacing(float)</a></td><td width="100%" class="jd-descrcol"><a target="_blank" class="operate-btn op-sound data-hover-tip" href="http://fanyi.baidu.com/translate?aldtype=16047&amp;query=Tint+to+apply+to+the+compound+%28left%2C+top%2C+etc.%29+drawables.+&amp;keyfrom=baidu&amp;smartresult=dict&amp;lang=auto2zh###" style="display:block"/><div class="trans-prompt"><p class="prompt-wrap"/></div><div class="original-mean-output"/><div class="trans-right clearfix"><div class="trans-output-wrap"><div class="output-container"><div class="output-wrap"><div class="output-mod ordinary-wrap"><div class="output-bd" dir="ltr" style="padding-bottom:0px"><p class="ordinary-output source-output" dir="ltr">Text letter-spacing.</p><p class="ordinary-output target-output"><span>文字字母间距</span></p></div></div></div></div></div></div></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:lineSpacingExtra">android:lineSpacingExtra</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setLineSpacing%28float,%20float%29">setLineSpacing(float,float)</a></td><td width="100%" class="jd-descrcol">控制两行文本之间的额外间距,与android:lineSpacingMultiplier属性结合使用</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:lineSpacingMultiplier">android:lineSpacingMultiplier</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setLineSpacing%28float,%20float%29">setLineSpacing(float,float)</a></td><td width="100%" class="jd-descrcol">控制两行文本之间的额外间距,每行的高度*该属性值+android:lineSpacingExtra属性值</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:lines">android:lines</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setLines%28int%29">setLines(int)</a></td><td width="100%" class="jd-descrcol">设置该文本框默认占用几行</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:linksClickable">android:linksClickable</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setLinksClickable%28boolean%29">setLinksClickable(boolean)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">控制该文本框的URL、E-mail等链接是否可用</span></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:marqueeRepeatLimit">android:marqueeRepeatLimit</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setMarqueeRepeatLimit%28int%29">setMarqueeRepeatLimit(int)</a></td><td width="100%" class="jd-descrcol">设置marquee动画重复的次数</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:maxEms">android:maxEms</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setMaxEms%28int%29">setMaxEms(int)</a></td><td width="100%" class="jd-descrcol">指定文本框的最大宽度</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:maxHeight">android:maxHeight</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setMaxHeight%28int%29">setMaxHeight(int)</a></td><td width="100%" class="jd-descrcol">指定文本框的醉倒高度</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:maxLength">android:maxLength</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setFilters%28android.text.InputFilter[]%29">setFilters(InputFilter)</a></td><td width="100%" class="jd-descrcol">设置文本框的最大字符长度</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:maxLines">android:maxLines</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setMaxLines%28int%29">setMaxLines(int)</a></td><td width="100%" class="jd-descrcol">设置文本框最多占用几行</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:maxWidth">android:maxWidth</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setMaxWidth%28int%29">setMaxWidth(int)</a></td><td width="100%" class="jd-descrcol">设置文本框的最大宽度(以px单位)</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:minEms">android:minEms</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setMinEms%28int%29">setMinEms(int)</a></td><td width="100%" class="jd-descrcol">设置文本框的最小宽度(以em单位)</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:minHeight">android:minHeight</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setMinHeight%28int%29">setMinHeight(int)</a></td><td width="100%" class="jd-descrcol">设置文本框的最小高度(以px单位)</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:minLines">android:minLines</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setMinLines%28int%29">setMinLines(int)</a></td><td width="100%" class="jd-descrcol">设为文本框最少占用几行</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:minWidth">android:minWidth</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setMinWidth%28int%29">setMinWidth(int)</a></td><td width="100%" class="jd-descrcol">设置文本框的最大宽度(以px单位)</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:numeric">android:numeric</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setKeyListener%28android.text.method.KeyListener%29">setKeyListener(KeyListener)</a></td><td width="100%" class="jd-descrcol"><div><span style="color:#ff0000">设置该文本框关联的输入法,有以下属性值:</span></div><div><span style="color:#ff0000"><br/></span></div><div><span style="color:#ff0000">  integer:指定关联整数输入法</span></div><div><span style="color:#ff0000">  signed:允许输入符号的数值输入法</span></div><div><span style="color:#ff0000">  decimal:允许输入小数点的数值输入法</span></div><div><br/></div></td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:password">android:password</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setTransformationMethod%28android.text.method.TransformationMethod%29">setTransformationMethod(TransformationMethod)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本框为一个密码框(以 *  代替字符)</span></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:phoneNumber">android:phoneNumber</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setKeyListener%28android.text.method.KeyListener%29">setKeyListener(KeyListener)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本框为只能接受电话号码 </span></td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:privateImeOptions">android:privateImeOptions</a></td><td class="jd-linkcol"><div>setPrivateImeOptions(String)</div></td><td width="100%" class="jd-descrcol"> </td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:scrollHorizontally">android:scrollHorizontally</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setHorizontallyScrolling%28boolean%29">setHorizontallyScrolling(boolean)</a></td><td width="100%" class="jd-descrcol"> </td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:selectAllOnFocus">android:selectAllOnFocus</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setSelectAllOnFocus%28boolean%29">setSelectAllOnFocus(boolean)</a></td><td width="100%" class="jd-descrcol">设置文本框的内容可选择时,是否在获得焦点时整个文本的内容都被选中</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:shadowColor">android:shadowColor</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setShadowLayer%28float,%20float,%20float,%20int%29">setShadowLayer(float,float,float,int)</a></td><td width="100%" class="jd-descrcol">设置文本框中文本的阴影颜色</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:shadowDx">android:shadowDx</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setShadowLayer%28float,%20float,%20float,%20int%29">setShadowLayer(float,float,float,int)</a></td><td width="100%" class="jd-descrcol">设置文本框内的文本的阴影在水平方向的偏移量</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:shadowDy">android:shadowDy</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setShadowLayer%28float,%20float,%20float,%20int%29">setShadowLayer(float,float,float,int)</a>设置文本框内的文本的阴影在水平方向的偏移量</td><td width="100%" class="jd-descrcol"> </td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:shadowRadius">android:shadowRadius</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setShadowLayer%28float,%20float,%20float,%20int%29">setShadowLayer(float,float,float,int)</a></td><td width="100%" class="jd-descrcol">设置文本框中文本阴影的模糊程度,值越大越模糊</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:singleLine">android:singleLine</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setTransformationMethod%28android.text.method.TransformationMethod%29">setTransformationMethod(TransformationMethod)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本框中文本是否不换行,设置为true,则不换行,为单行</span></td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:text">android:text</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setText%28java.lang.CharSequence,%20android.widget.TextView.BufferType%29">setText(CharSequence,TextView.BufferType)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本框中文本显示的内容</span></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textAllCaps">android:textAllCaps</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setAllCaps%28boolean%29">setAllCaps(boolean)</a></td><td width="100%" class="jd-descrcol">设置是否将文本框中的文本的所有字母显示为大写字母</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textAppearance">android:textAppearance</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setTextAppearance%28int%29">setTextAppearance(int)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设为文本框的颜色、字体、大小等样式</span></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textColor">android:textColor</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setTextColor%28int%29">setTextColor(int)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本框的文本的颜色</span></td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textColorHighlight">android:textColorHighlight</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setHighlightColor%28int%29">setHighlightColor(int)</a></td><td width="100%" class="jd-descrcol">设置文本框中文本被选中的颜色</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textColorHint">android:textColorHint</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setHintTextColor%28int%29">setHintTextColor(int)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本框中提示文本的颜色</span></td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textColorLink">android:textColorLink</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setLinkTextColor%28int%29">setLinkTextColor(int)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本框中超链接的颜色</span></td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textIsSelectable">android:textIsSelectable</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#isTextSelectable%28%29">isTextSelectable()</a></td><td width="100%" class="jd-descrcol">设置文本框不能被编辑时,文本框内的文本是否可以被选中</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textScaleX">android:textScaleX</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setTextScaleX%28float%29">setTextScaleX(float)</a></td><td width="100%" class="jd-descrcol">设置文本框中文本在水平方向上的缩放因子</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textSize">android:textSize</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setTextSize%28int,%20float%29">setTextSize(int,float)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置文本框内文本的字号大小</span></td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:textStyle">android:textStyle</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setTypeface%28android.graphics.Typeface%29">setTypeface(Typeface)</a></td><td width="100%" class="jd-descrcol">设置文本框中文本的字体风格,如  粗体、斜体</td></tr><tr class=" api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:typeface">android:typeface</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setTypeface%28android.graphics.Typeface%29">setTypeface(Typeface)</a></td><td width="100%" class="jd-descrcol">设置文本框内文本的字体风格</td></tr><tr class="alt-color api apilevel-"><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#attr_android:width">android:width</a></td><td class="jd-linkcol"><a target="_blank" href="file:///E:/Android/sdk/docs/reference/android/widget/TextView.html#setWidth%28int%29">setWidth(int)</a></td><td width="100%" class="jd-descrcol"><span style="color:#ff0000">设置该文本框的宽度</span></td></tr></tbody></table> 下面是TextView 的一些效果,如下面的图: ![](https://box.kancloud.cn/2016-04-26_571f42c86824d.jpg)                 ![](https://box.kancloud.cn/2016-04-26_571f42c88d34a.jpg) 2.EditText。的重要方法如下; 通过官网,我们可以看到,官网给出了EditText的一些方法。如下: ![](https://box.kancloud.cn/2016-04-26_571f42c8a653e.jpg) 其中最重要的就是  getText() 这个方法。通过这个方法,可以获得EditText中的文本信息。这样就能提取信息,一般都是在登陆界面和评论的地方,通过getText()方法来获取用户输入的内容。然后,把这些内容发送到服务器,然后提交服务器成功后。然后就把最新的评论数据从网络中返回到手机上。然后手机上面呈现出最新的评论结果。好了TetxtView和Edittext的方法和xml属性就介绍完了,然后如果不记得textview和EditText的xml属性是什么属性的话就查看上面的xml属性表。