1

I have an activity with a coloured background and a button which is the same colour which I want to minimally show with a white outline.

I used this answer to make a border on a button and it works just fine for me on Nexus 4 and 5 running 4.4.4

I try it on a Samsung S2 running 4.0.3 and the entire button turns black. No border. The button should be same colour as the activity with a white border. Text colour on the button (white) is just fine

Here is my border.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >


<corners android:radius="3dp" />

<stroke
    android:width="1px"
    android:color="#ffffff" />

</shape>

Can anyone explain the different behaviour, and more importantly tell me how to fix it?

Thanks

Edit Well I don't have a real answer, but I think I'm going to fix it by adding in

    <solid android:color="@color/mycolor" />

To my drawable shape. I think this works, but it's not very elegant if I want to have a transparent background. I may try setting the color to transparent at some point (on the assumption that some phones/versions of Android default to a black background and this is that easy to change), but no time for it now.

Community
  • 1
  • 1
Kibi
  • 1,860
  • 1
  • 29
  • 39
  • try applying the styles.xml in values-11 / values-14 folders as well – Mike Sep 23 '14 at 16:05
  • Hey @Mike, this is not actually a Style - I simply have android:background="@drawable/border" in my button. Should I create drawable-11 and drawable-14 ? I've never seen those before – Kibi Oct 06 '14 at 09:47
  • Instead of declaring it in android:background, declare a style for it. Then use it in xml as follows @Style/borderstyle where your borderstyle contains @drawable/border as one of its characteristics. – Mike Oct 06 '14 at 12:53

0 Answers0