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.
<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
Post a Comment