android - styles.xml 和 theme.xml 有什么区别

标签 android android-theme android-styles

我可以知道 styles.xmlthemes.xml 有什么区别吗?对我来说,它们只是看起来相同,因为两个 XML 格式相同。

<style name="...
    <item name="...

那么,在我的应用程序中提供自定义颜色、大小、可绘制……我是否也需要 styles.xmlthemes.xml ?我应该如何决定将哪个 XML 放入哪个文件?

最佳答案

出了Styles and Themes的整页.您可能正在寻找这条线。

When you apply a style to a single View in the layout, the properties defined by the style are applied only to that View. If a style is applied to a ViewGroup, the child View elements will not inherit the style properties—only the element to which you directly apply the style will apply its properties. However, you can apply a style so that it applies to all View elements—by applying the style as a theme.

当您应用为主题时,它会更改范围内的所有内容,具体取决于您将其应用到 Activity 还是 Application。风格更“本地化”。

关于android - styles.xml 和 theme.xml 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15170421/

相关文章:

android - 了解主题和样式属性之间的区别

android - AppCompat Force Holo 主题

安卓搜索栏风格

java - Activity 恢复时 ExpandableListAdapter getChildrenCount 空指针异常

java - 布局底部有两个按钮的 ScrollView

android - 为什么使用相同主题时 PreferenceActivity 和 Activity 看起来不同?

android - Android 按钮的圆角 + 背景颜色动态设置?

android - 使用 AlertDialog.Builder.setCustomTitle() 时设置默认文本样式

Android:更改 fragment 中的layout.xml

android - 使用-sdk :minSdkVersion 16 cannot be smaller than version 23 declared in library