1.TextView
TextView可以说是Android中最简单的一个控件了。它主要用于在界面上显示一段文字信息。
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
这是HelloWorld项目中的一段代码,android:layout_width指定了控件的宽度,同样的android:layout_height指定了控件的高度。
Android中所有的控件都有这两个属性,可选值有三种:match_parent、fill_parent、wrap_content。其中前两个的属性其实是一样的,都表示当前控件的大小和父布局的大小一样。Wrap_content表示让当前控件的大小恰好能包裹期内容。通过修改text属性所代表的值们可以改变界面中显示的文字信息。
TextView中文字默认左上角对齐。
<TextView
android:id="@+id/world"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="c