ano*_*ous 5 android android-appcompat
当主题从Theme.AppCompat.Light.DarkActionBar扩展时,如何在整个应用程序中设置textview,edittexts的样式?
这不起作用,
<style name="myTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:textViewStyle">@style/myTextViewStyle</item>
<item name="textViewStyle">@style/myTextViewStyle</item>
</style>
<style name="myTextViewStyle" parent="android:Widget.TextView">
<item name="android:layout_marginLeft">5dp</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:layout_marginBottom">5dp</item>
<item name="android:textColor">@android:color/black</item>
</style>
Run Code Online (Sandbox Code Playgroud)
<!-- Maintain *theme* naming convention Theme.ThemeName. It helps with organization. -->
<style name="Theme.MyApp" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textViewStyle">@style/Widget.MyApp.TextView</item>
<!-- AppCompat does not provide its own variant of textViewStyle attribute. -->
<item name="editTextStyle">@style/Widget.MyApp.EditText</item>
</style>
<!-- Maintain *style* naming convention Widget.ThemeName.WidgetName. -->
<!-- TextView is a simple widget, use the parent provided by platform. -->
<style name="Widget.MyApp.TextView" parent="android:Widget.TextView">
<!-- ... -->
</style>
<!-- EditText parent is provided by AppCompat. -->
<style name="Widget.MyApp.EditText" parent="Widget.AppCompat.EditText">
<!-- ... -->
</style>
Run Code Online (Sandbox Code Playgroud)
只要您的应用程序或活动已android:theme="@style/Theme.MyApp在清单中定义,它就可以工作。
几点注意事项:
widgetNameStyle在您的主题中覆盖。android:。android:如果存在 -prefixed 和 unprefixed 变体,请不要覆盖它们!只有一个有效。TextView和ProgressBar)。android:theme属性)。样式用于小部件(style属性)。| 归档时间: |
|
| 查看次数: |
1412 次 |
| 最近记录: |