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. JUnit failing with warning - ""test class not found in selected project"

Env:

Eclipse 3.5, Android 0.9.6, Windows XP SP2

Using the Android New project wizard I create a project and a test
project.

Add a simple test to test project extending AndroidTestCase - works
fine.

Add another test to test project extending ProviderTestCase2 - fails.
the JUnit view shows a green bar but with a warning node under the
junit.framework.TestSuite1 node.

When I click on the warning node I see - "test class not found in
selected project"

This is all out of the box - no changes made to the underlying
environment. No useful output in either the Console or LogCat view.

Any suggestions ?

-- 

2. Sygic CFI Problem

I use avd(API Level 4) run Sygic Application that I request from
Sygic.com for testing.
I try to write CFI to control application (put .in file in '/sdcard'),
but I cannot find any .out and it doesn't run.Please help me.

-- 

3. Problem in packagin .apk from flex application

4. how can application notice that a hotplug device is connected to the system?

5. custom seekbar

6. Android browser - how to disable the green click animation

7. Getting entity/body from an http post request