5

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>
R. Zagórski
  • 20,020
  • 5
  • 65
  • 90
vinodh kumar
  • 137
  • 2
  • 10
  • What do you mean by "didn't work in API level 16". WHAT didn't work? What is the outcome and what would you expect? – Bruno Bieri Jul 01 '20 at 06:40

1 Answers1

8

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>
R. Zagórski
  • 20,020
  • 5
  • 65
  • 90
  • That is not a solution when it comes to change the background color programmatically. Any ideas? or have to give up API16 as bottom target? – nnyerges Feb 22 '19 at 18:14
  • 1
    The answer is almost always out there: https://stackoverflow.com/a/17825210/6507689 – R. Zagórski Feb 22 '19 at 18:35