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. Application Manager & Force Close

Hello Everybody,
Im having the following issue.
The ApplicationManager is killing the process of my application when the
user presses on "FORCE STOP" on the Aplication Manager.

MENU-> SETTINGS -> APPLICATIONS -> MANAGE APPLICATIONS -> My APP .> FORCE
STOP.

According to the documentation a broadcast action is sent:
Intent.ACTION_PACKAGE_RESTARTED

Broadcast Action: The user has restarted a package, and all of its processes
have been killed. All runtime state associated with it (processes, alarms,
notifications, etc) should be removed. *Note that the restarted package does
not  receive this broadcast.* The data contains the name of the package.

How can I listen that action in my application; I have tried creating a
BroadcastReceiver on my package, but the onReceive() is not called.

I added the following to my receiver on the manifest, but nothing changed.

<receiver android:name=".MyReceiver">
  <intent-filter>
     <action android:name="android.intent.action.PACKAGE_RESTARTED"/>
  </intent-filter>
</receiver>

Emy

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

2. Regarding error Missing shared library

Hi all,

    I am trying to use google translate api, I have added it as a
library, I have added tags into Manifest.xml file as below

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="srs.la"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".Starter"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
<uses-library android:name="com.google.api.translate"/>
    </application>
<uses-permission android:name="android.permission.INTERNET"></uses-
permission>

</manifest>


Still I get error in LogCat as "Missing Shared Library
com.google.api.translate" And I am using Android 2.0.1 API 6, Could
any body help me fix this bug?

-- 

3. Hosts file ignored when connecting to APN with proxy:XX.XX.XX.XX:8080

4. Location Based Service Agents for Mobile Software Distribution

5. RFC: EventLog.Event.getTimeNanos()

6. App store and android x86

7. battery usage in animation