how to fill the color of image according to percentage of textview in android

后端 未结 3 1566
悲&欢浪女
悲&欢浪女 2020-12-11 13:55

How to fill the image according to percentage of textview.and it should change according to percentage of textview.below is my code so please check.

                 


        
3条回答
  •  伪装坚强ぢ
    2020-12-11 14:02

    if u want to change the opacity then you can simply set the opacity according to the value in textview usinf setalpha method.

    I have a good idea to solve this simply try it your self.

    Put your imageview in a linear/relative layout set the heightto the max width that u want to assign for the image view.

    Then initially set the heightof the image view to zero

    Then depending on the value from textview set the height of the image view programatically

     int x=Integer.parseInt(battery.getText().toString());
    
     image_level.getLayoutParams().height = x;
    

提交回复
热议问题