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!
-
1change to imagebutton and put the background like this: android:background="@android:color/transparent– DynaJan 9, 2015 at 18:58
-
Thanks very much , yes that was the problem , could you add it as an answer so I can select it. thanks– m0j1Jan 9, 2015 at 19:02
-
1Possible duplicate of Removing the shadow on an android button– Henrique de SousaJan 24, 2016 at 0:17
Add a comment
|
2 Answers
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"/>
-
3This is a great solution, except it requires API level 21. Is there a solution that will work for lower API levels?– BarnabyAug 27, 2015 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? Sep 23, 2015 at 8:40
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 ;)
-
5
-