问题在减少评分栏的大小。评分、大小、问题

2023-09-03 21:33:07 作者:不爱請早說

我要降低评级的大小吧,我得到了一些可供做到这一点,但他们是出于用户交互接触不到的地方,他们都只是指示。所以,请让我知道如何减少大小。先谢谢了。

I want to reduce the size of the Rating bar, I got some style properties that do it, but they are out of the reach of user interaction they are just Indicator. So, please let me know how to reduce the size. Thanks in advance.

推荐答案

如何胶给出的code的 此处 ...

How to glue the code given here ...

步骤1。你需要在 RES自己的等级分/绘制 ...

Step-1. You need your own rating stars in res/drawable ...

步骤2在 RES /绘制需要 ratingstars.xml 如下...

Step-2 In res/drawable you need ratingstars.xml as follow ...

<?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_empty" />
    <item android:id="@+android:id/secondaryProgress"
          android:drawable="@drawable/star_empty" />
    <item android:id="@+android:id/progress"
          android:drawable="@drawable/star" />
</layer-list>

步骤3在 RES /值需要 styles.xml 如下...

Step-3 In res/values you need styles.xml as follow ...

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="foodRatingBar" parent="@android:style/Widget.RatingBar">
        <item name="android:progressDrawable">@drawable/ratingstars</item>
        <item name="android:minHeight">22dip</item>
        <item name="android:maxHeight">22dip</item>
    </style>
</resources>

步骤4在布局...

<RatingBar 
      android:id="@+id/rtbProductRating"
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:numStars="5"
      android:rating="3.5"
      android:isIndicator="false"
      style="@style/foodRatingBar"    
/>  

尝试活动......

Try Activity ....

package x.y;

import android.app.Activity;
import android.os.Bundle;

public class RatingBarDemo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.product);

    }
}

通过这种布局 product.xml ...

With this layout product.xml ...

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5dip"
    android:paddingBottom="5dip">
    <ImageView
        android:id="@+id/imgProduct"
        android:layout_width="50dip"
        android:layout_height="50dip" 
        android:src="@drawable/icon" 
        android:scaleType="centerCrop"
        />
    <RelativeLayout
        android:id="@+id/layProductInfo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/imgProduct"
        android:paddingLeft="5dip"
        android:paddingRight="0dip"
        android:paddingTop="5dip"
        android:paddingBottom="5dip">  
        <TextView
            android:id="@+id/tvProductName"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Product Name"
            android:textSize="17dip" 
            />
        <RatingBar 
            android:id="@+id/rtbProductRating"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:numStars="5"
            android:rating="3.5"
            android:isIndicator="false"
            style="@style/foodRatingBar"
            android:layout_below="@id/tvProductName"
            />  
        <TextView
            android:id="@+id/tvPriceLabel"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="$45.87"
            android:layout_toRightOf="@id/rtbProductRating"
            android:layout_below="@id/tvProductName"
            android:paddingLeft="10dip"
            android:textSize="17dip" 
            />  
      </RelativeLayout>     
  </RelativeLayout>
 
精彩推荐
图片推荐