Removing the shadow on an android button

浪尽此生 提交于 2019-12-03 15:24:36

问题


I have searched and tryed all found solutions to this. I need to remove the shadow from a button in android. Most of the solutions i found involve using an imagebutton and setting it's background. I tryed that and it works but my button has text so imagebutton is not an option. Unless there is a way to write to an imagebutton?

My second solution was:

android:fadingEdgeLength="0dp"

But nothing seemed to change. Third:

android:shadowColor="@color/application_transparent" />

Nothing changed here either.

I also tryed creating a custom shape with stroke 0 and setting the buttons background to it but still nothing. I prefer to do this in my Xml rather than programmatically but if that is the only way, so be it. Thanks in advance


回答1:


How about

        <Button
           ..<code>

            android:stateListAnimator="@null"

           ..<code>
       </Button>



回答2:


Set Style Attribute for Button in xml

style="?android:attr/borderlessButtonStyle"

It Works.




回答3:


In my case, simply adding..

android:shadowRadius="0"

..in the xml file did the trick.




回答4:


Alternative for Attribute stateListAnimator used in API level 21 - I wrapped button inside a linear layout, both having same dimensions. Worked for my case.



来源:https://stackoverflow.com/questions/28744659/removing-the-shadow-on-an-android-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!