您必须指定通过绘制背景。
<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"
/>
,并在绘图资源文件夹背景
绘制/ 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>
你有活动定义的其他样式该按钮在添加?可能是一种风格添加了阴影?检查AndroidManifest.xml – peshkira
我没有添加任何样式 –
@null也适用于我。你在运行什么版本的Android? – peshkira