Android v7支持库attr引用

时间:2015-04-01 13:25:48

标签: android android-support-library android-resources android-styles

我一直在使用这个答案https://stackoverflow.com/a/11253806/2014236来设置具有对话框主题的活动的样式,使其看起来像一个AlertDialog。但是,我想使用支持库中提供的'attr'。如何引用android.support.v7.appcompat.R.attr buttonBarButtonStyle版本的android.R.attr而不是此处使用的<Button style="?android:attr/buttonBarButtonStyle" android:layout_height="wrap_content" android:layout_weight="wrap_content" android:text="Button" /> 版本:

style="?android.support.v7.appcompat:attr/buttonBarButtonStyle"

我尝试使用{{1}},但这会返回错误:

错误:找不到与给定名称匹配的资源('style'的值为'?android.support.v7.appcompat:attr / buttonBarButtonStyle')

尽管它位于指定的包中,如下所示:https://developer.android.com/reference/android/support/v7/appcompat/R.attr.html#buttonBarButtonStyle

使用非android attrs / styles的正确格式是什么?

1 个答案:

答案 0 :(得分:0)

看起来效果很好。

<Button style="?attr/buttonBarButtonStyle"
        android:layout_height="wrap_content"
        android:layout_weight="wrap_content"
        android:text="Button" />
相关问题