I use shapes to give my views (buttons) a rounded corner and a gradient. To switch between pressed, enabled and disabled I use a selector. Every item in the selector is a shape with an other gradient. Now I want to have all my shapes to have some default styles like all should have the same corner radius.
Selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_button_disabled"
android:state_enabled="false" />
<item android:drawable="@drawable/shape_button_pressed"
android:state_pressed="true" />
<item android:drawable="@drawable/shape_button_enabled" /></selector>
Shapes:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="@color/yellow_50"
android:endColor="@color/yellow_25"
android:angle="90"/>
<corners android:radius="5px"/>
How can I define the corner radius at only one spot?
Define your 5px as a dimension resource (dimens.xml)
http://developer.android.com/guide/topics/resources/more-resources.html#Dimension
Then you can access it from all your drawable shape files.
And access it as: