0

I can find many rounded-rectangle button but it is not working to me.

What do I miss?

It is layout.xml:

<LinearLayout
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="2"
    android:background="#ebf1ff"
    android:orientation="vertical">

    <LinearLayout
        style="@style/wrapperWidthWeightSumOne"
        android:paddingTop="50dp">

        <Button
            android:id="@+id/btnTypeAll"
            style="@style/ConsentTypeBtn"
            android:layout_width="0dp"
            android:layout_weight="0.85"
            android:text="All"/>
    </LinearLayout>

   (...)

</LinearLayout>

This is button's style:

<style name="ConsentTypeBtn">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:onClick">onClick</item>
    <item name="android:background">@drawable/selector_btn_consent_all</item>
    <item name="android:layout_marginBottom">2dp</item>
    <item name="android:singleLine">true</item>
    <item name="android:layout_gravity">center</item>
    <item name="android:textColor">#fff</item>
</style>

...and this is selector_btn_consent_all.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@drawable/consent_type_on">
    <shape android:shape="rectangle">
        <corners android:radius="4dp" />
        <stroke android:width="2dp" android:color="#1F3259"/>
    </shape>
</item>
<item android:state_pressed="true" android:drawable="@drawable/consent_type_on"></item>
<item android:drawable="@drawable/consent_type_off"></item>

Tomasz Dzieniak
  • 2,765
  • 3
  • 24
  • 42
Adrian
  • 301
  • 4
  • 15

1 Answers1

0

your selector_btn_consent_all.xml has status like this: when android:state_selected="true", use android:drawable="@drawable/consent_type_on".

So, find consent_type_on.xml at your drawable folder, and it would be rectangle, add <corners android:radius="4dp" />

EDIT

then, make consent_type_on.xml at your drawable folder. example here

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

    <corners android:radius="5dp" />
    <solid android:color="@android:color/holo_blue_bright" />

</shape>
myoungjin
  • 895
  • 1
  • 13
  • 27
  • consent_type_on is just hex of Color... in colors.xml – Adrian Aug 30 '16 at 08:14
  • check changes. if you want to change color of drawable's background(=solid), modify that `@android:color/holo_blue_bright` to your color hex code, or `@color/consent_type_on` – myoungjin Aug 30 '16 at 09:14