Margin/Padding of the stars in a RatingBar (or position and size)?
<p>I try to make an custom RatingBar for my Application which has a different image for each of the 4 stars.
With the following onDraw method it works quite good on my mobile.</p>

<pre><code>public class MyBar extends RatingBar {

    private int[] starArrayColor = { R.drawable.star_1_color, R.drawable.star_2_color, R.drawable.star_3_color, R.drawable.star_4_color };
    private int[] starArrayGrey = { R.drawable.star_1_grey, R.drawable.star_2_grey, R.drawable.star_3_grey, R.drawable.star_4_grey };

    (...)

    @Override
    protected synchronized void onDraw(Canvas canvas) {
        int stars = getNumStars();
        float rating = getRating();
        float x = 10;

        for (int i=0;i&lt;stars;i++) {
            Bitmap bitmap;
            Resources res = getResources();

            Paint paint = new Paint();
            paint.setAntiAlias(true);
            paint.setFilterBitmap(true);
            paint.setDither(true);

            if ((int) rating-1 == i) {
                paint.setAlpha(255);
                bitmap = BitmapFactory.decodeResource(res, starArrayColor[i]);
            } else {
                paint.setAlpha(70);
                bitmap = BitmapFactory.decodeResource(res, starArrayGrey[i]);
            }

            Bitmap scaled = Bitmap.createScaledBitmap(bitmap, 75, 75, true);
            canvas.drawBitmap(scaled, x, 12, paint);
            x += 96;
        }
    }
}
</code></pre>

<p>But the "calculation" of the x/y position and size of the images suc*s! Its just trial and error to get the right coordinates...</p>

<p>How can I calculate the position/size etc. to get it working properly on every device?</p>

<p>In the sources of AbsSeekBar/Progressbar I have found variables called mPaddingTop, mPaddingBottom etc. Is there a way to get those values?</p>
