Tuesday, January 15, 2013

[android-developers] Re: getting a 9-patch button working

Not sure, but here's my selector that I think works:

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

    <item android:drawable="@drawable/orange_button" android:state_enabled="false"/>
    <item android:drawable="@drawable/orange_button" android:state_enabled="true" android:state_pressed="true"/>
    <item android:drawable="@drawable/orange_button" android:state_enabled="true" android:state_focused="true"/>
    <item android:drawable="@drawable/blue_button" android:state_enabled="true"/>

</selector>



On Tuesday, January 15, 2013 6:45:54 AM UTC-6, dashman wrote:

Apologies - clarification - "Not working" means i don't see the background 9.png image.

I changed the Button element to point directly to the 9.png image - and that works.

from: <Button android:background="@drawable/dialpad_selector" </Button>

to: <Button android:background="@drawable/dialpad" </Button>


the reason the images are the same in the selector right now - is for test purposes.

once i can see it working - i plan to set the rest to different images.



On Monday, January 14, 2013 9:01:46 PM UTC-5, lbendlin wrote:
why do you use an XML template if it's the same picture for all states?
how did you create the nine patch?  Did you try it in an image view?

On Monday, January 14, 2013 3:52:05 PM UTC-5, dashman wrote:
got a button defined as

    <Button
        android:id="@+id/button1"
        android:background="@drawable/dialpad_selector"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello There" />


a dialpad_selector.xml as

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
          android:drawable="@drawable/dialpad" /> <!-- pressed -->
    <item android:state_focused="true"
          android:drawable="@drawable/dialpad" /> <!-- focused -->
    <item android:state_hovered="true"
          android:drawable="@drawable/dialpad" /> <!-- hovered -->
    <item android:drawable="@drawable/dialpad" /> <!-- default -->
</selector>

drawable dialpad is a 9-patch image

not working!



--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment