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=" http://schemas.android.com/apk/res/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 --
</selector>

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"></
ImageButton>

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?

Greetings,

maui

--



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. Removing labels on the MapView

Hi,

I was wondering if anyone would know a way to remove labels on the
MapView?

The documentation displays the following statement about the
"satellite" mode:

"Sets the map mode to "satellite" mode, loading tiles of aerial
imagery with roads and names superimposed."

Would anyone know if it's possible to work around it (I don't think
sources are available to take a look at it) or maybe if they intend to
do it later.

I don't get why they wouldn't provide us the choice to do so with the
MapView since it's already possible with the "regular" Google Maps.

I would appreciate any information about it.

Regards,

Issa Fortin

--~--~---------~--~----~------------~-------~--~----~

2. Android Market rejecting icons

I have finished the first version of my app and I am trying to upload
it to the market.  But every time I select my apk file for upload, the
market upload website says: The icon for your application is not
valid. Please use a 48x48 PNG.  I have checked my image and resaved it
in gimp at various dpi.  I have rebuilt several times.  I keep
gettin the same error. what gives?  Is there a fix?

--~--~---------~--~----~------------~-------~--~----~

3. Exit SMS-app after sending SMS

4. finishing subactivity after some perticular time

5. Upgrading android Application

6. adb push wtf

7. Problem with multi select listview with default selected List Items.