Button's background drawable (shape) won't

2019-06-28 05:26发布

In my Android app, I'm trying to set a simple ring shape as background drawable for my Buttons. But as much as I try, the XML preview ignores the background drawable unless the API level is set to 20 (Android L)

What's going on? I'm sure people used to set shapes for buttons before L.

Code for my XML shape for button_ring.xml located in /drawables folder

<?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>

and code for my button defined in layout folder

<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" />

My Gradle dependency

dependencies {
    compile 'com.android.support:support-v4:20.+'
}

and finally a video to see what I mean: Video

0条回答
登录 后发表回答