善用Android预定义样式
字体大小
对于能够显示文字的控件(如TextView, EditText, RadioButton, Button ,CheckBox ,Chronometer等等),你有时需要控制字体的大小。Android平台定义了三种字体大小。
复制到剪贴板 XML/HTML代码
1. "?android:attr/textAppearanceLarge"
2.
3. "?android:attr/textAppearanceMedium"
4.
5. "?android:attr/textAppearanceSmall"
使用方法为:
复制到剪贴板 XML代码
1. android:textAppearance="?android:attr/textAppearanceLarge"
2. android:textAppearance="?android:attr/textAppearanceMedium"
3. android:textAppearance="?android:attr/textAppearanceSmall"
4.
5. 或
6.
7. style="?android:attr/textAppearanceLarge"
8. style="?android:attr/textAppearanceMedium"
9. style="?android:attr/textAppearanceSmall"
字体颜色
复制到剪贴板 XML/HTML代码
1. android:textColor="?android:attr/textColorPrimary"
2. android:textColor="?android:attr/textColorSecondary"
3. android:textColor="?android:attr/textColorTertiary"
4. android:textColor="?android:attr/textColorPrimaryInverse"
5. android:textColor="?android:attr/textColorSecondaryInverse"
ProgressBar
复制到剪贴板 XML/HTML代码
1. style="?android:attr/progressBarStyleHorizontal"
2. style="?android:attr/progressBarStyleLarge"
3. style="?android:attr/progressBarStyleSmall"
4. style="?android:attr/progressBarStyleSmallTitle"
分隔符
复制到剪贴板 XML/HTML代码
1. 横向:
2.
3. <View android:layout_width="fill_parent"
4. android:layout_height="1dip"
5. android:background="?android:attr/listDivider" />
6.
7. 纵向:
8.
9. <View android:layout_width="1dip"
10. android:layout_height="fill_parent"
11. android:background="?android:attr/listDivider" />
CheckBox
复制到剪贴板 XML/HTML代码
1. style="?android:attr/starStyle"
类似标题栏效果的TextView
复制到剪贴板 XML/HTML代码
1. style="?android:attr/listSeparatorTextViewStyle"
其它有用的样式
复制到剪贴板 XML/HTML代码
1. android:layout_height="?android:attr/listPreferredItemHeight"
2.
3. android:paddingRight="?android:attr/scrollbarSize"
4.
5. style="?android:attr/windowTitleBackgroundStyle"
6.
7. style="?android:attr/windowTitleStyle"
8.
9. android:layout_height="?android:attr/windowTitleSize"
10.
11. android:background="?android:attr/windowBackground"