Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inherit drawable selector

I have a custom button style as follows:

<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:state_checked="true" >
    <shape>
        <gradient
            android:startColor="@color/Shadow"
            android:endColor="@color/Highlight"
            android:angle="270" />
        <stroke
            android:width="1dp"
            android:color="#000" />
        <corners
            android:radius="3dp" />
        <padding
            android:left="10dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp" />
    </shape>
</item>

<item android:state_pressed="true" >
    <shape>
        <gradient
            android:startColor="@color/Shadow"
            android:endColor="@color/Highlight"
            android:angle="270" />
        <stroke
            android:width="1dp"
            android:color="#000" />
        <corners
            android:radius="3dp" />
        <padding
            android:left="10dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp" />
    </shape>
</item>

<item>        
    <shape>
        <gradient
            android:startColor="@color/Shadow"
            android:endColor="@color/Highlight"
            android:angle="90" />
        <stroke
            android:width="1dp"
            android:color="#000" />
        <corners
            android:radius="50dp" />
        <padding
            android:top="10dp"
            android:bottom="10dp" />
    </shape>
</item>
</selector>

I now want to create a button that look like this except the right corners aren't rounded. I know how to set corner radius individually but is there a way to inherit all the other properties of my custom button?

I tried:

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">    
<item android:drawable="@drawable/custom_button">
    <shape>
          <corners android:topRightRadius="0dp"
              android:bottomRightRadius="0dp"/>
      </shape>
</item>
</selector>

but my corners tag seems to be completely ignored, the buttons just look like the custom_button. Any thoughts?

like image 831
Civatrix Avatar asked Mar 16 '12 01:03

Civatrix


1 Answers

<shape> and <corners> do not accept style attribute so I think there is nothing much that you can do about it.

like image 67
Naresh Avatar answered Nov 04 '22 06:11

Naresh