2011-09-29 23 views

उत्तर

0

आप अनुकूलित करने के लिए है RatingBar ..

हालांकि तुम सिर्फ RatingBar छवियाँ & तो रिवर्स गणना के कुछ प्रकार प्रदर्शित साथ चाल निभानी है।

चाल RatingBar में रिवर्स चित्र प्रदर्शित किया जाएगा .. RatingBar में अदला-बदली का चयन किया और इसे नहीं चुना जाता छवियों।

उपयोगकर्ता RatingBar पर रेट करने के लिए अनुमति दें। आपको चयनित और अचयनित गणनाओं को स्वैप करना होगा। मेरा मतलब है कि आपको रिवर्स गणना करना है। StackOverflow पर कस्टम RatingBar की

पूरा कार्य उदाहरण केवल मेरे द्वारा जवाब दे दिया।

डाउनलोड यहाँ से RatingBar प्रतीक: http://developer.android.com/guide/practices/ui_guidelines/icon_design.html

+0

धन्यवाद। मैं वास्तव में उछल एक आसान तरीका था ... –

4

आप अपने Ratingbar में android:rotation="180" उपयोग कर सकते हैं यह मैं पर मेरे रीड-ओनली Ratingbars इस तरह से इस्तेमाल किया घुमाने के लिए, मुझे नहीं पता है कि अगर यह Ratingbar के साथ बातचीत के प्रभाव होगा।

+1

तो आप भी ग्राफिक्स संपादक जो आसान न सिर्फ सितारों की रिवर्स राशि निर्धारित करने की तो है में ड्रॉएबल बारी बारी चाहिए –

+1

हाँ, 'एंड्रॉयड: rotationY = 180' एक आकर्षण की तरह काम करता .. । –

3

विशेषता का प्रयोग करें android:scaleX="-1"

या

package com.example.selection; 

import android.content.Context; 
import android.graphics.Canvas; 
import android.graphics.Matrix; 
import android.util.AttributeSet; 
import android.view.MotionEvent; 
import android.widget.RatingBar; 

public class InvertRatingBar extends RatingBar { 

    public InvertRatingBar(Context context) { 
     super(context); 
    } 

    public InvertRatingBar(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public InvertRatingBar(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
    } 

    @Override 
    public boolean onTouchEvent(MotionEvent event) { 
     int width = this.getMeasuredWidth(); 
     event.setLocation(width - event.getX(), event.getY()); 
     return super.onTouchEvent(event); 
    } 

    @Override 
    protected synchronized void onDraw(Canvas canvas) { 
     int width = this.getMeasuredWidth(); 
     Matrix matrix = canvas.getMatrix(); 
     matrix.preTranslate(width, 0); 
     matrix.preScale(-1.f, 1); 
     canvas.setMatrix(matrix); 
     super.onDraw(canvas); 
    } 
} 
संबंधित मुद्दे