Android: How do I set the textsize for a layout?
To set the global styling for all TextView
s, set the android:textViewStyle
attribute in a custom theme and apply the theme to your application or individual activities.
Pseudocode:
<style name="MyTheme" parent="android:Theme"> <item name="android:textViewStyle">@style/MyTextView</item></style><style name="MyTextView" parent="android:Widget.TextView"> <item name="android:textSize">14sp</item></style>...<activity android:theme="@style/MyTheme"> ...
Or if you wanted to set the default all around text style but override parts of it for certain things (like the button in this example) you could do something like this:
<style name="whiteText" parent="@android:style/TextAppearance.Medium"> <item name="android:textStyle">normal</item> <item name="android:textColor">@android:color/white</item> </style> <style name="buttonStyle" parent="@android:style/Widget.Button"> <item name="android:textAppearance">@style/whiteText</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@android:color/black</item> <item name="android:gravity">center</item> <item name="android:background">@drawable/pinkbutton</item> <item name="android:cacheColorHint">@android:color/transparent</item> <item name="android:minHeight">50.0dip</item> </style> <style name="DarkTheme" parent="@android:style/Theme.Black.NoTitleBar"> <item name="android:buttonStyle">@style/buttonStyle</item> <item name="android:textAppearance">@style/whiteText</item> </style>
Probably your single best place to get started though would be: http://developer.android.com/design/style/index.html