【发布时间】:2016-04-28 09:28:40
【问题描述】:
我正在尝试使用主题属性自定义我的微调器。 这是我的微调器项目布局
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/DashboardSpinnerItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:text="test"
android:textSize="@dimen/material_text_body1" />
我使用自定义样式
<style name="DashboardSpinnerItemStyle" parent="Widget.AppCompat.TextView.SpinnerItem">
<item name="android:textColor">?dashboard_color</item>
<item name="android:background">#00F</item>
</style>
我的主题中确定了属性颜色
<style name="WhiteDashboardTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColor">@android:color/white</item>
<item name="dashboard_shape">@drawable/dashboard_center_shape_white</item>
<item name="dashboard_color">@android:color/white</item>
<item name="spinner_background">@drawable/dashboard_spinner_white</item>
<item name="dashboard_spinner_item_style">@style/DashboardSpinnerItemStyle</item>
</style>
工作正常,但模拟器或真实设备会引发异常
04-28 09:01:44.909 2460-2460/com.amocrm.prototype E/AndroidRuntime: 致命异常: main android.view.InflateException: Binary XML file line #2: Error inflating class TextView
我做错了什么?
【问题讨论】:
标签: android android-spinner android-theme