change xml layout attribute dynamically




<item>
<shape android:shape="rectangle" >

<gradient
android:endColor="#FFFFFF"
android:startColor="#A9A9A9"
android:type="linear" />


<stroke
android:width="2dp"
android:color="#5E2612" />


<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
</shape>
</item>
<item
android:bottom="4dp"
android:left="4dp"
android:right="4dp"
android:top="4dp">
<shape android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="#A9A9A9"
android:startColor="#FFFFFF"
android:type="linear" />

<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />


</shape>
</item>


I have a background of a button as above. In my app, I allow user to change color of buttons (the startColor and endColor), of the two items.


Is it possible to set background for buttons dynamically in my situation?


No comments:

Post a Comment