android - how to change color of circle according to percentage -


i want show percentage of humidity in circle.and change color of circle dynamically accroding percentage of humidity. had created following layout.created 2 drawable 2 different color also.enter image description here

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@drawable/registration_bg"     >      <relativelayout         android:id="@+id/image_layout"         android:layout_width="@dimen/circleheight"         android:layout_height="@dimen/circleheight"         android:background="@drawable/circle1"         android:layout_below="@+id/linearlayout"         android:layout_centerinparent="true"         >         <button             android:id="@+id/image_level"             android:layout_width="@dimen/circleheight"             android:layout_height="@dimen/circleheight"             android:background="@drawable/circle2"             android:layout_centerinparent="true"             /> </relativelayout> </relativelayout> 

this mai layout file

following 2 drawable files

circle1.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >     <gradient android:startcolor="@color/circle1"         android:endcolor="@color/circle1"         android:angle="270"/> </shape>  circle2.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >     <gradient android:startcolor="@color/circle2"         android:endcolor="@color/circle2"         android:angle="270"/> </shape> 


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -