Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background shape didn't work perfectly in API level 16 in Android

Tags:

android

xml

I have designed one shape for applying to the background of my linear layout. it works perfect in API level 21. but didn't work in API level 16.please help me.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle">
    <stroke
       android:drawable="@android:id/background"
       android:width="3dp"
       android:color="#023e64">
    </stroke>

    <corners
        android:bottomLeftRadius="16dp"
        android:bottomRightRadius="16dp"
        android:topLeftRadius="16dp"
        android:topRightRadius="16dp"/>

</shape>
like image 246
vinodh kumar Avatar asked Sep 13 '16 12:09

vinodh kumar


1 Answers

It is a known bug, that on API 16 the drawable background becomes black.

Just set the background to android.color.R.transparent:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <stroke
        android:drawable="@android:id/background"
        android:width="3dp"
        android:color="#023e64">
    </stroke>
    <solid android:color="@android:color/transparent"/>


    <corners
        android:bottomLeftRadius="16dp"
        android:bottomRightRadius="16dp"
        android:topLeftRadius="16dp"
        android:topRightRadius="16dp"/>

</shape>
like image 67
R. Zagórski Avatar answered Oct 04 '22 23:10

R. Zagórski