I have added a simple button to my layout , and I have deleted the text and set an image with transparency as its background. but unfortunately there is a drop shadow effect on my button and I can't remove it. I'll appreciate if you have any experience with it help me.
Thanks!
Asked
Active
Viewed 2.9k times
18

m0j1
- 4,067
- 8
- 31
- 54
-
1change to imagebutton and put the background like this: android:background="@android:color/transparent – Dyna Jan 09 '15 at 18:58
-
Thanks very much , yes that was the problem , could you add it as an answer so I can select it. thanks – m0j1 Jan 09 '15 at 19:02
-
1Possible duplicate of [Removing the shadow on an android button](http://stackoverflow.com/questions/28744659/removing-the-shadow-on-an-android-button) – Henrique de Sousa Jan 24 '16 at 00:17
2 Answers
78
on Button tag set
android:stateListAnimator="@null"
example:
<Button
android:id="@+id/button1"
android:layout_height="50dp"
android:layout_width="match_parent"
android:stateListAnimator="@null"/>

msamardzic
- 1,060
- 9
- 12
-
3This is a great solution, except it requires API level 21. Is there a solution that will work for lower API levels? – Barnaby Aug 27 '15 at 15:19
-
5@Barnaby I guess that the "shadow" effect is added on Lollipop, so lower API levels will not show any shadow by default. Can anyone confirm this? – manelizzard Sep 23 '15 at 08:40
8
Your xml , instead of the button that you have, should be like this:
<ImageButton android:src="@drawable/yourimagename"
android:id="@+id/button1"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:background="@null"
/>
If you have any problems just let me know ;)

Dyna
- 2,304
- 1
- 14
- 25
-
5
-
See: http://stackoverflow.com/questions/28756035/how-to-remove-button-shadow-android – Roy Apr 03 '15 at 07:16