开发者

Customizing rating bar in android

开发者 https://www.devze.com 2023-04-09 13:38 出处:网络
I have to design a custon list item including rating bar in it I followed this tutorial([Problem with custom rating bar in android) for customising and resizing rating bar.Rating bar is now appering

I have to design a custon list item including rating bar in it

I followed this tutorial([Problem with custom rating bar in android) for customising and resizing rating bar.Rating bar is now appering small bt i am unable to click on it

My custom listItem Code is :

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:stretchColumns="*" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:id="@+id/tbl">
    <TableRow>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical" androi开发者_StackOverflow中文版d:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:src="@drawable/icon" />
            <TextView android:layout_width="wrap_content" android:id="@+id/txt"
                android:layout_height="wrap_content" android:text="Item Name" />
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical" android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <TextView android:layout_width="100dp" android:gravity="center"
                android:layout_height="wrap_content" android:text="Price" />
            <TextView android:layout_width="100dp" android:gravity="center"
                android:layout_height="wrap_content" android:text="Discount" />
            <TextView android:layout_width="100dp" android:gravity="center"
                android:layout_height="wrap_content" android:text="In Stock" />
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical" android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <!-- <RatingBar android:id="@+id/ratingBar1" android:fitsSystemWindows="false" 
                android:maxWidth="150dip" android:minHeight="23dip" android:maxHeight="25dip" 
                android:layout_height="40dp" android:layout_width="150dp" /> -->
            <TextView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="Shipping days" />
            <RatingBar android:id="@+id/ratingBar" style="?android:attr/ratingBarStyleSmall"
                android:layout_gravity="center_vertical|center_horizontal"
                android:focusable="true" android:layout_width="wrap_content"
                android:layout_height="wrap_content"></RatingBar>
            <Button android:layout_width="60dip" android:layout_height="35dip"
                android:text="Buy" android:textSize="15dip"/>
        </LinearLayout>
    </TableRow>
</TableLayout>

And the screenShot is :

Customizing rating bar in android

EDIT :

i developed the customized rating bar but now whatever i set the rating in landscape and when i look at the application in portrait whole rating bars are deselected..what to do to keep rating bar selected ?


The smaller RatingBar style ( ratingBarStyleSmall) and the larger indicator-only style (ratingBarStyleIndicator) do not support user interaction and should only be used as indicators. (from RatingBar manual)


Use drawables with different sizes for HDPI and MDPI, and then give your ratingbar a specific height in dp. Or, put one empty row of pixels in your drawable. but the second way just solves the look of your ratingbars, and the height will be wrong. I suggest the first way.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号