Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit</strong></p> <p>Have a look at custom rating in motorola <a href="http://community.developer.motorola.com/t5/Android-App-Development-for/custom-rating-bar-style-using-android-s-ratingBar-small-style/td-p/10462" rel="noreferrer">http://community.developer.motorola.com/t5/Android-App-Development-for/custom-rating-bar-style-using-android-s-ratingBar-small-style/td-p/10462</a></p> <p><strong>Updated</strong></p> <p>styles.xml</p> <p>This must be located in your values folder</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="foodRatingBar" parent="@android:style/Widget.RatingBar"&gt; &lt;item name="android:progressDrawable"&gt;@drawable/food_rating_bar_full&lt;/item&gt; &lt;item name="android:minHeight"&gt;23dip&lt;/item&gt; &lt;item name="android:maxHeight"&gt;25dip&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>food_rating_bar_full.xml</p> <p>This file must be in Drawable folder.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:id="@+id/background" android:drawable="@drawable/food_ratingbar_full_empty" /&gt; &lt;item android:id="@+id/secondaryProgress" android:drawable="@drawable/food_ratingbar_full_empty" /&gt; &lt;item android:id="@+id/progress" android:drawable="@drawable/food_ratingbar_full_filled" /&gt; &lt;/layer-list&gt; </code></pre> <p>food_ratingbar_full_empty.xml</p> <p>This file must be inside Drawable folder.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;!-- This is the rating bar drawable that is used to show a filled cookie. --&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true" android:state_window_focused="true" android:drawable="@drawable/cookiee" /&gt; &lt;item android:state_focused="true" android:state_window_focused="true" android:drawable="@drawable/cookiee" /&gt; &lt;item android:state_selected="true" android:state_window_focused="true" android:drawable="@drawable/cookiee" /&gt; &lt;item android:drawable="@drawable/cookiee" /&gt; &lt;/selector&gt; </code></pre> <p>food_ratingbar_full_filled.xml</p> <p>This file must be located in Drawable folder.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;!-- This is the rating bar drawable that is used to show a unfilled cookie. --&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true" android:state_window_focused="true" android:drawable="@drawable/cookie" /&gt; &lt;item android:state_focused="true" android:state_window_focused="true" android:drawable="@drawable/cookie" /&gt; &lt;item android:state_selected="true" android:state_window_focused="true" android:drawable="@drawable/cookie" /&gt; &lt;item android:drawable="@drawable/cookie" /&gt; &lt;/selector&gt; </code></pre> <p>main.xml file should look like :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;RatingBar android:id="@+id/ratingBar1" style="@style/foodRatingBar" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;/RatingBar&gt; &lt;/LinearLayout&gt; </code></pre> <p>MainActivity.class should look like :</p> <pre><code>import android.app.Activity; import android.os.Bundle; import android.widget.RatingBar; import android.widget.RatingBar.OnRatingBarChangeListener; import android.widget.Toast; public class MainActivity extends Activity { /** Called when the activity is first created. */ RatingBar rb; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); rb=(RatingBar)findViewById(R.id.ratingBar1); rb.setOnRatingBarChangeListener(new OnRatingBarChangeListener(){ @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(),Float.toString(rating),Toast.LENGTH_LONG).show(); } }); } } </code></pre> <p>I have used two images:</p> <p>cookie.jpg</p> <p>cookiee.jpg</p> <p>This two images are of same size one is used for identifying selected Rating Bar and other for identifying unselected RatingBar</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload