读书人

Android 2.2 API 汉语文档系列(2)

发布时间: 2012-12-19 14:13:15 作者: rapoo

Android 2.2 API 中文文档系列(2) —— EditText

正文

  一、结构

  java.lang.Object
  ? android.view.View
  ? android.widget.TextView? ? ? ?
  ? android.widget.

2010-8-31_1.jpg(3.46 K)
2010-8-31_2.jpg(12.47 K)
? ?

android:text

? ?

设置显示文本.

? ?

android:textAppearance

? 设置文字外观。如“?android:attr/textAppearanceLargeInverse?

”这里引用的是系统自带的一个外观,?表示系统是否有这种外观,否则使用默认的外观。可设置的值如下:textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/textAppearanceMediumInverse/textAppearanceSmall/textAppearanceSmallInverse

? ?

android:textColor

? ?

设置文本颜色

? ?

android:textColorHighlight

? ?

被选中文字的底色,默认为蓝色

? ?

android:textColorHint

? ?

设置提示信息文字的颜色,默认为灰色。与hint一起使用。

? ?

android:textColorLink

? ?

文字链接的颜色.

? ?

android:textScaleX

? ?

设置文字之间间隔,默认为1.0f。参见TextView的截图。

? ?

android:textSize

? ?

设置文字大小,推荐度量单位”sp”,如”15sp”

? ?

android:textStyle

? ?

设置字形[bold(粗体) 0, italic(斜体) 1,? bolditalic(又粗又斜) 2] 可以设置一个或多个,用“|”隔开

? ?

android:typeface

? ?

设置文本字体,必须是以下常量值之一:normal 0, sans 1, serif 2,? monospace(等宽字体) 3]

? ?

android:height

? ?

设置文本区域的高度,支持度量单位:px(像素)/dp/sp/in/mm(毫米)

? ?

android:maxHeight

? ?

设置文本区域的最大高度

? ?

android:minHeight

? ?

设置文本区域的最小高度

? ?

android:width

? ?

设置文本区域的宽度,支持度量单位:px(像素)/dp/sp/in/mm(毫米),与layout_width的区别看这里。

? ?

android:maxWidth

? ?

设置文本区域的最大宽度

? ?

android:minWidth

? ?

设置文本区域的最小宽度


    补充说明:

  a).  由于是继承自TextView,所以属性是一样的,但是这里重点补充了输入法相关的属性说明和研究,部分注释也做了相应的调整。

  b).  Word格式下载
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="100dp" android:layout_height="wrap_content"></EditText>
((EditText)findViewById(R.id.txtTest)).setOnEditorActionListener(new TextView.OnEditorActionListener() {
? ? ? ? ? ? @Override
? ? ? ? ? ? public boolean onEditorAction(TextView v, int actionId,
? ? ? ? ? ? ? ? ? ? KeyEvent event) {
? ? ? ? ? ? ? ? if (actionId == EditorInfo.IME_ACTION_GO) {
? ? ? ? ? ? ? ? ? ? Toast.makeText(TestActivity.this, "你点了Go!", Toast.LENGTH_SHORT).show();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? return false;
? ? ? ? ? ? }
? ? ? ? });
复制代码

结束

读书人网 >Android

热点推荐