【发布时间】:2016-02-20 06:51:39
【问题描述】:
我正在尝试设置评分栏的样式。我为评分栏创建了样式并将其添加到我的评分栏。但是评分栏忽略了它的风格并从 AppTheme 中挑选出来。 这是两种风格
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorControlNormal">#ffffff</item>
</style>
<style name="MyMaterialTheme" parent="AppTheme"/>
<style name="foodRatingBar" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/rating_stars</item>
<item name="android:minHeight">48dip</item> <!-- your desired size -->
<item name="android:maxHeight">48dip</item> <!-- your desired size -->
</style>
rating_stars.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"
android:drawable="@drawable/star_selected" />
<item android:id="@android:id/secondaryProgress"
android:drawable="@drawable/star_selected" />
<item android:id="@android:id/progress"
android:drawable="@drawable/stsr" />
</layer-list>
评分栏 xml
<RatingBar
android:theme="@style/foodRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:numStars="5"
android:isIndicator="false" />
在应用此样式时,它仍然从 AppTheme 中选择颜色:colorCntrolNormal、colorAccent。 这种方式是错误的还是我错过了什么?
【问题讨论】:
-
使用 android:theme="@style/yourTheme"
-
我已经在用了
-
然后尝试将其放入您的评分栏主题
- @color/RatingAccentColor