您必須指定通過繪製背景。
<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