How to create Custom Ratings bar in Android

前端 未结 13 1440
故里飘歌
故里飘歌 2020-11-22 06:28

Hello all i need to perform Ratings in my application... SO i need to create custom Ratings bar... Can Anyone Help me in this?

13条回答
  •  庸人自扰
    2020-11-22 07:14

    first add images to drawable:

    the first picture "ratingbar_staroff.png" and the second "ratingbar_staron.png"

    After, create "ratingbar.xml" on res/drawable

    
    
    
        
        
        
    
    

    the next xml the same on res/drawable

    "ratingbar_empty.xml"

    
    
    
        
    
        
    
        
    
        
    
    
    

    "ratingbar_filled"

    
    
    
        
    
        
    
        
    
        
    
    
    

    the next to do, add these lines of code on res/values/styles

    
    

    Now, already can add style to ratingbar resource

            
    

    finally on your activity only is declare:

    RatingBar ratingbar = (RatingBar) findViewById(R.id.ratingbar);
    ratingbar.setRating(3.67f);
    

提交回复
热议问题