XML drawable having different behavior on 4.3 and 4.1.2
Asked Answered
I

2

8

I have the folowing drawable,

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <corners android:radius="3dp"/>
    <padding android:left="1dp" android:right="1dp" android:top="1dp" android:bottom="1dp"/>
     <stroke android:width="1dp" android:color="#e4e4e4"/>

</shape>

"It supposed" to draw a border when set on background, actually on (Android 4.3 /goole nexus 7) it does , but unfortunately on (Android 4.1.2/ Samsung galaxy tab 10") it just fill all the background with the color

If someone can tell me what I'm doing wrong, or if someone has an xml drawable for border, I will be very thankful :=)

Insufferable answered 17/9, 2013 at 14:31 Comment(5)
increase your padding to 5dp tryAutotomize
Ichanged the padding with the folowing: <padding android:left="5dp" android:right="5dp" android:top="5dp" android:bottom="5dp"/> but I have the same issueInsufferable
i just tried and it works for me. i just changed the padding to 5p. increase your padding more and try. i tested it on a phone not on a tabletAutotomize
strange :( for me even when I remove the pading line completly I have this issue, thanksInsufferable
I finally found a better drawable I put it as answer :)Insufferable
I
19

here is the solution with the same drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="@android:color/transparent" />
    <corners android:radius="3dp"/>
    <stroke android:width="1dip" android:color="#e2e2e2"/>
</shape>

I needed just to specify solid color :

 <solid android:color="@android:color/transparent" />
Insufferable answered 23/1, 2014 at 14:57 Comment(0)
I
1

code of a border drawable that works better on both versions :

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the line -->
    <item android:top="1px" android:right="1px" android:left="1px" android:bottom="1px">
      <shape>
            <solid android:color="@android:color/transparent" />
            <corners android:radius="3dp"/>
            <stroke android:width="1px" android:color="#e4e4e4" />
      </shape>
    </item>

</layer-list>
Insufferable answered 19/9, 2013 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.