Android style and theme (1): android style theme
Main. the attributes defined by each component in xml code are duplicated. To avoid the hassle of defining repeated attributes of each component in a file: res/values/
Style_test.xml source code:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Resources>
<Style name = "CodeFont" parent = "@ android: style/TextAppearance. Medium">
<Item name = "android: layout_width"> match_parent </item>
<Item name = "android: layout_height"> wrap_content </item>
<Item name = "android: textSize"> 16sp </item>
</Style>
</Resources>
Modify the main. xml file as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<TableLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent"
Android: stretchColumns = "1"
Android: background = "@ drawable/bluesky"
>
<! -- Account -->
<TableRow>
<TextView
Style = "@ style/CodeFont"
Android: text = "account :"
/>
<EditText
Style = "@ style/CodeFont"
Android: hint = "mobile phone number"
Android: selectAllOnFocus = "true"
/>
</TableRow>
<! -- Password -->
<TableRow>
<TextView
Style = "@ style/CodeFont"
Android: text = "Password :"
/>
<EditText
Style = "@ style/CodeFont"
Android: inputType = "numberPassword"
/>
</TableRow>
<! -- Birthday -->
<TableRow>
<TextView
Style = "@ style/CodeFont"
Android: text = "birthday :"
/>
<EditText
Style = "@ style/CodeFont"
Android: inputType = "date"
/>
</TableRow>
<! -- Address -->
<TableRow>
<TextView
Style = "@ style/CodeFont"
Android: text = "Address :"
/>
<EditText
Style = "@ style/CodeFont"
Android: inputType = "textPostalAddress"
/>
</TableRow>
<! -- Email -->
<TableRow>
<TextView
Style = "@ style/CodeFont"
Android: text = "Email :"
/>
<EditText
Style = "@ style/CodeFont"
Android: inputType = "textEmailAddress"
/>
</TableRow>
<! -- Register -->
<TableRow>
<Button
Style = "@ style/CodeFont"
Android: text = "register"
/>
</TableRow>
</TableLayout>
The running result is still.