Top Menu

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Showing posts with label Rating Bar. Show all posts
Showing posts with label Rating Bar. Show all posts

Tuesday, 25 July 2017

How can I decrease the size of Ratingbar?

There are two ways you can do this.
You have to style the RatingBar with either ratingBarStyleSmall or a custom style inheriting from Widget.Material.RatingBar.Small (assuming you're using Material Design in your app).

Option 1:
<RatingBar android:id="@+id/ratingBar" style="?android:attr/ratingBarStyleSmall" ... />
Option 2:

// styles.xml<style name="customRatingBar" parent parent="android:style/Widget.Material.RatingBar.Small"> ... // Additional customizations</style> // layout.xml<RatingBar android:id="@+id/ratingBar" style="@style/customRatingBar" ... />
Read more...

Android Material Rating Bar - Rating Bar example in Material Design

Rating Bar

How to add?

I. In your build.gradle add latest appcompat library.
dependencies { compile
compile 'com.android.support:appcompat-v7:X.X.X' // where X.X.X version}
II. Make your activity extend android.support.v7.app.AppCompatActivity.
public class MainActivity extends AppCompatActivity { ...}
III. Declare your RatingBar inside any layout.xml file.
<RatingBar android:rating="3.5" android:stepSize="0.5" android:numStars="5" android:layout_width="wrap_content" android:layout_height="wrap_content"/>

How to style?


I. Declare custom style in your styles.xml file.
<style name="RatingBar" parent="Theme.AppCompat"> <item name="colorControlNormal">@color/indigo</item> <item name="colorControlActivated">@color/pink</item></style>
II. Apply this style to your RatingBar via android:theme attribute.

<RatingBar android:theme="@style/RatingBar" android:rating="3" android:stepSize="0.5" android:numStars="5" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
Read more...