Reputation: 164
I created a button, set the background to @null
, but shadow is still there.
How can I remove the shadow?
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:background="@null"
android:text="Random" />
Upvotes: 0
Views: 3486
Reputation: 7571
You have to specify a background via a drawable.
<Button
android:id="@+id/shadowless_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background_button"
android:text="Press Me"
/>
and a background in the drawables folder
drawable/background_button.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<!-- view background color -->
<solid android:color="@android:color/darker_gray"></solid>
<!-- view border color and width -->
<stroke android:width="1dp" android:color="@android:color/black"></stroke>
<!-- If you want to add some padding -->
<!-- Here is the corner radius -->
<corners android:radius="4dp"></corners>
</shape>
</item>
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<!-- view background color -->
<solid android:color="@android:color/white"></solid>
<!-- view border color and width -->
<stroke android:width="1dp" android:color="@android:color/darker_gray"></stroke>
<!-- If you want to add some padding -->
<!-- Here is the corner radius -->
<corners android:radius="4dp"></corners>
</shape>
</item>
</selector>
Upvotes: 0
Reputation: 617
Try that:
android:background="@android:color/transparent"
BTW: your background as null works for me without the shadow
Upvotes: 1