Closed jatin-lakhani closed 7 years ago
You can achieve it using gravity
left
in your LinearLayout and layout_width
wrap_content
in the rating bars:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical"
android:animateLayoutChanges="true"
>
<com.iarcuschin.simpleratingbar.SimpleRatingBar
android:id="@+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:srb_fillColor="@color/material_red300"
app:srb_borderColor="@color/material_red500"
app:srb_pressedFillColor="@color/material_redA200"
app:srb_pressedBorderColor="@color/material_redA400"
app:srb_numberOfStars="5"
app:srb_gravity="left"
/>
<com.iarcuschin.simpleratingbar.SimpleRatingBar
android:id="@+id/ratingBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:srb_fillColor="@color/material_blue300"
app:srb_borderColor="@color/material_blue500"
app:srb_pressedFillColor="@color/material_blueA200"
app:srb_pressedBorderColor="@color/material_blueA400"
app:srb_numberOfStars="4"
app:srb_gravity="left"
/>
<com.iarcuschin.simpleratingbar.SimpleRatingBar
android:id="@+id/ratingBar3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:srb_fillColor="@color/material_green300"
app:srb_borderColor="@color/material_green500"
app:srb_pressedFillColor="@color/material_greenA700"
app:srb_pressedBorderColor="@color/material_green700"
app:srb_numberOfStars="3"
app:srb_gravity="left"
/>
<com.iarcuschin.simpleratingbar.SimpleRatingBar
android:id="@+id/ratingBar4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:srb_fillColor="@color/material_amber300"
app:srb_borderColor="@color/material_amber500"
app:srb_pressedFillColor="@color/material_amberA400"
app:srb_pressedBorderColor="@color/material_amberA700"
app:srb_numberOfStars="2"
app:srb_gravity="right"
/>
<com.iarcuschin.simpleratingbar.SimpleRatingBar
android:id="@+id/ratingBar5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:srb_fillColor="@color/material_purple300"
app:srb_borderColor="@color/material_purple500"
app:srb_pressedFillColor="@color/material_purpleA200"
app:srb_pressedBorderColor="@color/material_purpleA400"
app:srb_numberOfStars="1"
app:srb_gravity="right"
/>
</LinearLayout>
</ScrollView>
Which outputs:
How can i achieve the mirror effect of above pattern?
* * * *
* * *
* *
*
Hi, @jatin-lakhani. You can change the gravity
in the LinearLayout to achive it:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="vertical"
android:animateLayoutChanges="true"
>
I want to make pyramid of starts like below pattern
* (5 star) ** (4 star) * (3 star) ** (2 star)
So I want to maintain star gravity to left only. I have given all the rating bar's width to fixed DP.
Can you help me to achieve output like above?