Android中样式和主题的优先顺序是什么? [英] What's the precedence of styles and themes in Android?

查看:129
本文介绍了Android中样式和主题的优先顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很难调试的问题,我想要一个布局文件,该文件的按钮完全根据活动"代码进行样式设置.因为android:layout_widthandroid: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.

  1. 小部件的内联属性,这些属性会覆盖...
  2. styles.xml文件中的样式,这些样式将覆盖...
  3. 窗口小部件的默认样式,将覆盖...
  4. 主题指定的样式

这篇关于Android中样式和主题的优先顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆