Button's background drawable (shape) won't show up unless app API is 20+ (Android L)

落花浮王杯 提交于 2019-12-23 13:28:08

问题


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

来源:https://stackoverflow.com/questions/24951003/buttons-background-drawable-shape-wont-show-up-unless-app-api-is-20-androi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!