TextView
1 2 3 4 5 6 7 8
| <TextView android:id="@+id/text_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:textSize="32sp" android:textColor="#00ff00" android:text="This is TextView" />
|
1 2 3 4 5 6
| <Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button" android:textAllCaps="false" />
|
EditText
1 2 3 4 5 6 7
| <EditText android:id="@+id/edit_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Type something here" android:maxLines="2" />
|
ImageView
1 2 3 4 5 6
| <ImageView android:id="@+id/image_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/img_1 " />
|
ProgressBar
1 2 3 4 5 6 7
| <ProgressBar android:id="@+id/progress_bar" android:layout_width="match_parent" android:layout_height="wrap_content" style="?android:attr/progressBarStyleHorizontal" android:max="100" />
|
控件属性:
android:id=”@+id/XXXX”
android:layout_width=”XXX” && android:layout_height=”XXX”
- 控件宽高
- 父容器决定尺寸:match_parent(推荐) && fill_parent
- 内容决定尺寸:wrap_content
android:gravity=”XXX”
- 控件对齐方式
- top、bottom、left、right、 center
- 可以用“|”来指定多个值
android:textSize=”XXXsp”
android:textColor=”#00ff00”
android:textAllCaps=”false”
- button属性
- 小写到大写转换(button默认开启)
android:text=”helo”
android:hint=”Type something here”
- editText属性
- 类似web的placeholder
android:maxLines=”2”
android:src=”@drawable/img_1”
style=”?android:attr/progressBarStyleHorizontal”
android:max=”100”
本文作者: haise
本文地址: https://www.shifeng1993.com/2018/04/27/android2/
版权声明: 转载请注明出处!