Using Selector to change ImageButton's background while keeping the content image

by Sebastian Mauer » Sun, 18 Apr 2010 23:18:36 GMT

Sponsored Links
 Hi there,

I am currently trying to customize ImageButton to show different
draweables as background of the Button while keeping
the image set via the src attribute.

That's my custom_button.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="" ;>
     <item android:state_pressed="true"
           android:drawable="@drawable/round_list_item" /> <!--
pressed -->
     <item android:state_focused="true"
           android:drawable="@drawable/round_list_item" /> <!--
focused -->
     <item android:drawable="@drawable/transparent" /> <!-- default --

And this is the actual definition of the ImageButton:
<ImageButton android:background="@drawable/custom_button"
android:src="@drawable/attach_icon" android:id="@+id/test_button"
android:layout_height="35dip" android:layout_width="35dip"></

Unfortunately all I get is the background from the selector xml
(whichs is btw working as expected) but not the image I have set via
the src attribute.
So basically all I want is to replace the standard state background
drawables while keeping the ability to set a foreground/content image.

Am I doing something wrong here?




Using Selector to change ImageButton's background while keeping the content image

by Sebastian Mauer » Wed, 21 Apr 2010 03:32:04 GMT

 Is this even possible?


Sponsored Links

Other Threads

1. MP3 to PCM 16 Bit

With the new 1.5 now finally being released, I'm trying to give my app
a second go.

I currently have a service where you can stream your music library
from the web. However, each stream has to be authenticated with a
cookie or the server returns a 500 error, so the standard MediaPlayer
will not work, because I cannot pass a cookie with the Uri!

I noticed that the API now has an AudioTrack class within It can take a raw stream of PCM 16 BIT. I was wondering
if anyone has any tips or ideas on progmatically transcoding MP3
stream to PCM 16 for playing through.


2. signed 1.5 does not work.. probs with 1.5

He said "-t 1" which means "target platform number 1". In the SDK the
first platform is API 2. Yeah a bit confusing, I agree.

The install process cannot change the signing key of an app.

If you push an apk with a debug key (which is what happens when you
run from eclipse), you cannot install a signed apk directly. You need
to uninstall the debug version first. Works the other way too: if you
install a signed apk, you cannot install a debug version from eclipse.

You cannot push a non-signed apk at all iirc. It has to be signed
either by the eclipse/ant debug key or by you manually.



3. Article: Mobile App developers seek to cash in on iPhone apps.

4. Marketplace question

5. 1.5 update issue: Emulator won't launch - Failed fo find and AVD error

6. iPhone like Tab Widget

7. signed 1.5 does not work.. probs with 1.5