Android中样式和主题的优先顺序是什么? [英] What's the precedence of styles and themes in Android?
问题描述
我有一个很难调试的问题,我想要一个布局文件,该文件的按钮完全根据活动"代码进行样式设置.因为android:layout_width
和android:layout_height
不能通过主题设置,而需要通过布局文件中的特定style="@style/myButton"
设置,所以一切都变成了意大利面.
I had a hard to debug problem where I wanted to have a layout file with buttons that were completely styled from the Activity code. Because android:layout_width
and android:layout_height
can't be set by themes and need be set by specific style="@style/myButton"
in the layout files, everything went spaghetti.
最重要的是,我不能使用主题来完全控制Activity
代码中的样式.但是在Activity
代码中完全生成布局是很痛苦的,因为您没有获得Graphical Layout View
来轻松预览更改.
Bottom line is I can't use themes to completely control styles from the Activity
code. But completely generating layouts in the Activity
code is painful because you don't get the Graphical Layout View
to easily preview changes.
推荐答案
来自这篇精彩的博文我发现几天已经太晚了.
From this wonderful blog post I found a few days too late.
- 小部件的内联属性,这些属性会覆盖...
- styles.xml文件中的样式,这些样式将覆盖...
- 窗口小部件的默认样式,将覆盖...
- 主题指定的样式
这篇关于Android中样式和主题的优先顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!