<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=""
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <ImageView 
        android:id="@+id/p_w_picpath"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
       />
    <RatingBar android:id="@+id/rating"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:numStars="5"
        android:max="255"
        android:progress="255"
        android:stepSize="0.5"/>

</LinearLayout>

 

 

package com.example.ratingbar;

import android.os.Bundle;

import android.app.Activity;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;

public class MainActivity extends Activity {

 @Override

 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  final ImageView p_w_picpath=(ImageView) findViewById(R.id.p_w_picpath);
  p_w_picpath.setImageResource(R.drawable.ic_launcher);
  RatingBar ratingBar=(RatingBar) findViewById(R.id.rating);
  ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
   @Override
   public void onRatingChanged(RatingBar ratingBar, float rating,
     boolean fromUser) {
    p_w_picpath.setAlpha((int)(rating*255/5));
   }
  });
 }

}