私の Android アプリでは、ボタンの描画可能な背景として単純なリング形状を設定しようとしています。しかし、API レベルが 20 (Android L) に設定されていない限り、 XML プレビューはバックグラウンド ドローアブルを無視します。
どうしたの?L より前は、ボタンの形状を設定していたはずです。
button_ring.xml
/drawables フォルダーにあるXML 形状のコード
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring" >
<solid android:color="#4CD964" />
</shape>
レイアウトフォルダーで定義されたボタンのコード
<Button
android:id="@+id/button5"
android:layout_weight="1"
android:text="@string/five"
android:tag="@string/five"
style="@style/CustomButton"
android:background="@drawable/button_ring" />
私のGradle依存関係
dependencies {
compile 'com.android.support:support-v4:20.+'
}
そして最後に、私が何を意味するかを確認するためのビデオ:ビデオ