Dom*_*rtl 6 xml android themes coding-style widget
有没有办法格式化所有TextViews,按钮或任何主题?就像我想要格式化所有a-tags时的CSS一样
a {/ some css here /}
我想在我的应用程序中应用主题时,通过xml在android中执行此操作.有什么想法?谢谢
更新1.0: 我想创建一个主题,格式化所有TextViews绿色和所有EditTexts红色文本.所以我只是应用主题,我永远不必担心风格属性!
更新1.1: 所以我发现了一些代码,我认为这是一个好的开始
<item name="android:textViewStyle">@style/MyTextView</item>
<item name="android:buttonStyle">@style/MyButton</item>
Run Code Online (Sandbox Code Playgroud)
我认为这就是我的问题的答案.但我有另一个.我想编写自己的ActionBar并想知道如何应用默认样式或默认属性(同样不在布局xml中添加样式属性:P)
我上课了
public class ActionBar extends LinearLayout{ }
Run Code Online (Sandbox Code Playgroud)
我会在我的应用程序中使用它
<at.bartinger.uil.ActionBar>....</at.bartinger.uil.ActionBar>
Run Code Online (Sandbox Code Playgroud)
ActionBar应该有一些默认属性(如高度和宽度),然后添加一些自定义样式属性,这些属性可以从app更改为app(如背景)
是的,您可以将主题应用于整个应用程序,然后所有文本视图都将具有该样式。
在 styles.xml 文件中,您必须定义 CustomTheme
例如:
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">@color/custom_theme_color</item>
<item name="android:colorBackground">@color/custom_theme_color</item>
</style>
Run Code Online (Sandbox Code Playgroud)
您添加类似文本“android:textStyle=”myStyle”的内容并在 Mystyle 中指定详细信息