【问题标题】:What is the difference between andoid:xxx and xxx?andoid:xxx 和 xxx 有什么区别?
【发布时间】:2018-04-01 07:56:26
【问题描述】:

我想改变Dialog的NegativeButton的颜色;

这是通过样式实现的一种自然方式:

values-21/styles.xml

<style name="BaseDialogStyle" parent="ThemeOverlay.AppCompat.Dialog.Alert">
    <item name="buttonBarNegativeButtonStyle">@style/NegativeButtonBarButtonStyle</item>
</style>

<style name="NegativeButtonBarButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
    <item name="android:textColor">#00ffff</item>
</style>

但是,如果我把名字改成android:buttonBarNegativeButtonStyle,就不行了。这是为什么呢?

非常感谢~

【问题讨论】:

    标签: android android-styles


    【解决方案1】:

    “android”是属性资源的包前缀。前缀取决于您使用的资源。

    <item name="[package:]style_property_name">style_value</item>
    

    (来自:https://developer.android.com/guide/topics/resources/style-resource.html

    通常“android”用于已由 android 定义的元素和小部件。当属性用于应用程序本身的自定义时,一般没有前缀

    【讨论】:

      猜你喜欢
      • 2016-01-13
      • 2014-10-03
      • 2012-01-15
      • 1970-01-01
      • 2018-03-06
      • 1970-01-01
      • 2017-08-26
      • 2010-10-02
      • 2011-12-12
      相关资源
      最近更新 更多