Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: api 16 draws outline of rectangle as filled rectangle

The following code on api 21 shows the outline of a rectangle with a black border of 1 px width:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke android:width="1dp" android:color="#000000" />
    <size android:width="300dp" android:height="50dp"/> 
</shape>

However, on api 16 I'm seeing a solid black rectangle. Why is this and is there a workaround?

Edit: in the logcat I'm seeing continuous messages of:

HardwareRenderer﹕ draw surface is valid dirty= Rect(107, 214 - 109, 251)
like image 514
Jon Avatar asked Jul 23 '15 15:07

Jon


1 Answers

I had the same problem few weeks ago. I finally added a transparent solid. Try with:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke android:width="1dp" android:color="#000000" />
    <size android:width="300dp" android:height="50dp"/>
    <solid android:color="@android:color/transparent" />
</shape>
like image 61
Mimmo Grottoli Avatar answered Oct 01 '22 21:10

Mimmo Grottoli