I had tried it, but when I want to use a "selector" for my button, it
seems the dither can't work again.


res/drawable/keyboard_speeddial_normal_dithered.xml:

<nine-patch xmlns:android="http://schemas.android.com/apk/res/android";
android:src="@drawable/keydialer_normal" android:dither="true" />

res/drawable/keyboard_speeddial.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android";>
    <item android:state_pressed="true"
        android:drawable="@drawable/keyboard_speeddial_press" />
    <item android:state_focused="true"
        android:drawable="@drawable/keyboard_speeddial_focus" />
    <item
        android:drawable="@drawable/
keyboard_speeddial_normal_dithered" />
</selector>

I set the "keyboard_speeddial" as the background of a RelativeLayout.

By the way, if I wrap the keyboard_speeddial into another dither xml
file such like:

res/drawable/keyboard_speeddial_dithered.xml:
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android";
android:src="@drawable/keyboard_speeddial" android:dither="true" />

It will cause a runtime exception.


On 5月6日, 上午3時37分, Jeff Sharkey <jshar...@android.com> wrote:
> It also works for creating dithered 9-patches:
>
> res/drawable/proxy_nine_patch.xml:
> <nine-patch android:src="@drawable/original_nine_patch" android:dither="true" 
> />
>
> j
>
>
>
> On Tue, May 5, 2009 at 11:32 AM, Romain Guy <romain...@google.com> wrote:
>
> > It's just a typo. Here's a proxy example:
>
> > <bitmap android:src="@drawable/my_png_image" />
>
> > Doing so lets you for instance enable or disable dithering using 
> > android:dither.
>
> > On Tue, May 5, 2009 at 10:25 AM, Ward Willats <goo...@wardco.com> wrote:
>
> >> In the "widget design guidelines"  under "widget graphics tips and
> >> tricks" is says
>
> >> "In some cases, devices that have low pixel depths that can cause
> >> visual banding and dithering issues. To solve this, application
> >> developers should pass assets through a "proxy" drawable defined as
> >> XML:. This technique references the original artwork, in this case
> >> "background.9.png", and instructs the device to dither it as needed."
> >>Jus
> >> Eh?
>
> >> I mean, I can see an .xml drawable that points to my .png (not sure
> >> which type I would use) but I don't understand what this
> >> http-method-ish "XML:" syntax is referencing.
>
> >> Can someone elaborate on this whole technique?
>
> >> Thanks
>
> >> -- Ward
>
> > --
> > Romain Guy
> > Android framework engineer
> > romain...@android.com
>
> > Note: please don't send private questions to me, as I don't have time
> > to provide private support.  All such questions should be posted on
> > public forums, where I and others can see and answer them
>
> --
> Jeff Sharkey
> jshar...@google.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to