最近在项目中碰到一个问题,就是在Android5.0版本以上,button会自带阴影效果,但苦逼的是我们的产品要我们去掉阴影效果,以下提供两种方法:
1.直接在要去掉button的XML文件中加:
设置该属性就可以去掉自带的阴影。
该属性在API 11及以上可用。
style="?android:attr/borderlessButtonStyle"
具体配置:
<Button android:id="@+id/app_item_open" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:focusable="false" style="?android:attr/borderlessButtonStyle" android:text="体验"/>2.直接在style中设置:
<style name="ButtonStyle3" parent="Base.Widget.AppCompat.Button.Borderless"> <item name="android:background">@drawable/box_blue_conner_white_background</item> <item name="android:gravity">center</item> <item name="android:textColor">@color/home_content_blue</item> <item name="android:textSize">17sp</item> <item name="android:padding">5dp</item> </style>