b_yng
b_yng

Reputation: 14136

Nine-patch StateListDrawable rendering issue

After updating to SDK tools revision 15 from revision 12, my EditTexts and Buttons all appear distorted like so...

How it looks now How it used to look

Now is this a bug with the revision? Because when I preview what the layout looks like with the "Graphical Layout" tab it appears normal. But as soon as it is compiled and put on my phone or the emulator, it is distorted.

Here is the StateListDrawable xml for the buttons. Each drawable referenced in this is a 9patch. The EditTexts are done in the same fashion.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/button_grey_pressed" android:state_pressed="true"></item>
    <item android:drawable="@drawable/button_grey_pressed" android:state_focused="true"></item>
    <item android:drawable="@drawable/button_grey_pressed" android:state_selected="true"></item>
    <item android:drawable="@drawable/button_grey_default"></item>
</selector>

Upvotes: 5

Views: 622

Answers (3)

Geordie
Geordie

Reputation: 11

I've copied and pasted from here and it worked:

  1. Disable auto-refresh, build automatically.
  2. Full clean all projects.
  3. Build all projects.
  4. Clean the main project.
  5. Build the main project.

Upvotes: 1

Mangusto
Mangusto

Reputation: 1505

This is an issue I've had too when I updated to SDK 14.

I found a solution in Window>Preferences>Android>Build by setting "Build output" on Normal and then Project>Clean>Clean All.

Upvotes: 2

a.ch.
a.ch.

Reputation: 8390

Try wrapping those nine-patch drawables (I suppose @drawable/button_grey_pressed refers to /drawable/button_grey_pressed.9.png) into xml nine-patch drawables:

<?xml version="1.0" encoding="utf-8"?>
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/button_grey_pressed"
    android:dither="true" />

You will have to give this xml file the name which will be different from that of button_grey_pressed.9.png, let's say button_grey_pressed9.xml

Upvotes: 0

Related Questions