[英]android ratingbar size
我終於找到了如何更改ratingBar的圖像,但我無法弄清楚如何更改大小。 我有這個
<resources>
<style name="foodRatingBarSmall" parent="@android:style/Widget.RatingBar.Small">
<item name="android:progressDrawable">@drawable/rating_bar_used</item>
<item name="android:minHeight">10dip</item>
<item name="android:maxHeight">10dip</item>
</style>
</resources>
但每當我改變minHeight
和maxHeight
的大小時,它都保持不變。
我的布局xml:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="fill_parent" android:onClick="showRecipeOnClick" android:clickable="true" style="@style/row">
<TableRow
android:id="@+id/tableRow1" android:layout_gravity="center" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center_vertical">
<TextView android:id="@+id/customName"
android:textSize="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="@color/black"
android:layout_weight="5">
</TextView>
<RatingBar android:id="@+id/mainRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="0.5"
android:isIndicator="true"
android:layout_gravity="center_vertical"
style="@style/foodRatingBarSmall"></RatingBar>
</TableRow>
<View android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="@color/black"/>
</TableLayout>
我究竟做錯了什么?
謝謝您的幫助
從中更改樣式
parent="@android:style/Widget.RatingBar.Small"
至
parent="@*android:style/Widget.RatingBar.Small"
有關更多信息,請參閱以下鏈接,尤其是從6開始的評論。
解決方案包括將scale屬性應用於RatingBar,因此它不是非常精確:
<RatingBar android:id="@+id/mainRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="0.5"
android:isIndicator="true"
android:layout_gravity="center_vertical"
style="@style/foodRatingBarSmall"
android:scaleX="0.8"
android:scaleY="0.8"></RatingBar>
星星較小,交互仍然有效
當我從1.6切換到2.1時,我遇到了同樣奇怪的問題。 刪除你風格的小詞並嘗試:
android:style/Widget.RatingBar.Small
至
android:style/Widget.RatingBar
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.