1.TextView

用于在屏幕上显示文本,可以显示单行文本,多行文本,和带图像的文本。

常用xml属性

(1)android:autoLink,用于指定是否将指定的文本转换为可单机的超链接形式,其属性值有none,web,email,phone,map和all

(2)android:drawableBottom;android:drawableLeft;android:drawableRight;android:drawableTop 分别表示文本框在在各个位置的指定图像

(3)android:gravity 用于设置文本框内文本的对齐方式 ,其属性值可以组合,用“|”隔开

(4)android:hint 用于设置当文本框中内容为空的时候,默认的显示的提示文字

(5)android:inputType 用于指定文本的显示类型,其可选值有 textPassword,textEmailAddress,phone,date等,可以同时指定多个,用“|”隔开。

(6)android:singleLine 用于指定文本框是否为单行模式。其属性值是true或者false。默认的是false

(7)android:text 要显示文本的内容

(8)android:textColor 要显示文本的颜色,其属性值可以是#rgb,#argb,#rrggbb,#aarrggbb格式指定的颜色值。

(9)android:textSize 用于设置文本框类字体的大小,其属性值由数值和单位组成,其单位可以是px,pt,sp,in,pd。

(9)android:width;android:height;用于指定文本的宽度高度,已像素为单位。

TextView的使用实例

<TextView        android:id="@+id/textView1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="@string/email"        android:autoLink="email"         android:gravity="center"        android:height="40px"/>    <TextView        android:id="@+id/textView2"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:drawableTop="@drawable/ic_launcher"        android:text="@string/imageTextView" />    <TextView        android:id="@+id/textView3"        android:textSize="20px"        android:textColor="#0f0"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="@string/text" />    <TextView        android:id="@+id/textView4"        android:textSize="20px"        android:textColor="#f00"        android:singleLine="true"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="@string/text" />    <TextView        android:id="@+id/textView5"        android:layout_width="wrap_content"        android:inputType="textUri"        android:layout_height="wrap_content"        android:text="www.baidu.com" />

  效果如下

2 EditText

EditText是TextView的子类,所以TextView的Xml属性,EditText都有,其中android:inputType属性可以帮助输入框显示合适的类型。

<requestFocus />会获得焦点,意思就是如果你给某个edittext设置了<requestFocus />标记,并且这个edittext前面没有设置<requestFocus />标记的控件那么这个edittext就会获得焦点,也就是输入的那个光标。

更多相关文章

  1. android组建属性及使用许可
  2. 《疯狂Android讲义》学习笔记二
  3. 【Android】declare-styleable属性值
  4. android 布局 ListView中的列表 RelativeLayout
  5. 14、NFC技术:使用Android(安卓)Beam技术传输文本
  6. android中根据控件宽度,实现展示文本内容,解决中英文自动换行
  7. Android布局文件中命名空间的解析
  8. android:layout_gravity和android:gravity属性的区别
  9. android:layout_gravity和android:gravity属性的区别

随机推荐

  1. 在Python / IPython解释器中为单个下划线
  2. 深入理解python中得闭包
  3. 16讲 序列!序列!
  4. Python数据分析相关资料
  5. Python环境那点儿事(Windows篇)
  6. [python每日一练]--0001:生成激活码
  7. 对于mysql django,NULL和FALSE是一样的吗?
  8. python--数据库支持
  9. Python3 基础:条件判断和循环&三元运算符
  10. 《数据结构与算法Python语言描述》裘宗燕