0

SOLUTION: Well its my emulator and eclipse layout editor. On a real phone it works just fine :(

QUESTION:

android:topLeftRadius for corners is overriding the topRight, bottomRight, and bottomLeft.

So while I want the right side to be rounded the left side should be squared yet both sides are squaring.

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

<solid android:color="#F000" />

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

<padding
    android:bottom="7dp"
    android:left="10dp"
    android:right="10dp"
    android:top="7dp" />

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

<gradient
    android:angle="90"
    android:centerColor="#00004C"
    android:endColor="#000099"
    android:startColor="#000000"
    android:type="linear" />

</shape>

I am just calling it in xml of a button.

android:background="@drawable/button_layout"

Rick
  • 1,153
  • 1
  • 18
  • 37

2 Answers2

0

You have forgotten that you need a <shape> around your attributes. This code works for me:

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

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

  <padding
     android:bottom="7dp"
     android:left="10dp"
     android:right="10dp"
     android:top="7dp" />

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

  <gradient
     android:angle="90"
     android:centerColor="#00004C"
     android:endColor="#000099"
     android:startColor="#000000"
    android:type="linear" />

</shape>
Sprigg
  • 3,340
  • 1
  • 18
  • 26
  • you have forgotten to put a ``` around your parameters. I edited my answer. – Sprigg Sep 18 '13 at 15:01
  • sorry that was a copy and paste error then stack kicking the tag. I do have it and edited my post – Rick Sep 18 '13 at 15:09
  • like i said: for me it is working. Maybe there are some other factors involved? – Sprigg Sep 18 '13 at 15:12
  • i built a new project with only a textview button and this layout and its still not working. Building on 4.3 for 2.2 I wonder if thats it. – Rick Sep 18 '13 at 15:35
0

This might be connected to a bug in Android versions prior to 3.0 (see https://code.google.com/p/android/issues/detail?id=9161)

You can solve it by having separate drawable folders for the different api versions.

see also Something's wrong in Corner radius Android

Community
  • 1
  • 1
Lovis
  • 9,513
  • 5
  • 31
  • 47
  • yea I read this and will have to use it but that is not whats going on here. But thank you it does help – Rick Sep 18 '13 at 15:50