I’ve been working on my application for a while in Android 2.2, and I’m pretty happy with it. However, technology advances and it’s time to upgrade the old girl to work with Honeycomb and ICS…
One of the things that’s not looking right is the buttons on my screen. It’s frustrating, but I can’t seem to find a way to make them look the way they used to. My buttons use a custom drawable, which is an XML file, not an actual graphic. It looks like this:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:startColor="#444444"
android:endColor="#444444" />
<stroke
android:width="1dip"
android:antialias="true"
android:color="@android:color/white" />
<corners
android:radius="8dip" />
<padding
android:left="2dip"
android:top="2dip"
android:right="2dip"
android:bottom="2dip" />
</shape>
</item>
</selector>
The buttons grab this code in the layout.xml file like this:
<Button
android:id="@+id/button1"
android:layout_weight="1"
android:layout_width="1dp"
android:layout_margin="2dp"
android:longClickable="true"
android:visibility="invisible"
android:layout_height="fill_parent"
android:background="@drawable/def_gray"
android:layout_gravity="center_vertical"
android:textColor="@android:color/white"
android:gravity="center_horizontal|center_vertical" />
This used to produce a nice, professional-looking rounded-corner rectangle button with a white border and a gray center. However, now that I’m running my code on a Samsung Galaxy Tab 2 (running ICS) the rounded parts of the border are not white — they’re gray, and it looks bad. I have discovered the corners will be white if I fatten up the stroke to 2dip, but I really would prefer to preserve the earlier version look of the software.
I’ve learned from experience that if I were drawing something with curves with a Paint & Canvas, the answer to this problem is to ensure that anti-aliasing is on. However, even though there IS an android:antialias key for XML (you can see it in the section — but it doesn’t work), I can’t figure out how to use it.
Does anyone have any suggestions??
Thanks,
R.
The only answer I could find was to grow the size of the white outline from 1dp to 2dp.
The reason I can think of that this would work is color-aliasing for the curved line, but I was unsuccessful at addressing the issue directly. At first, it really wasn’t the look I was going for, but it’s grown on me.