How do I place an image on top of my existing layout through code?

by idev » Wed, 29 Apr 2009 15:35:01 GMT

Sponsored Links

I have a layout in which I am displaying a webview. I want to add
images on top of the webview at specific places through code.

Can some one please tell me how to do that?

The translucent background example in API Demos makes the view cover
the whole screen. I want to place only a small image and at a specific
location (origin not 0,0)

Thanks a lot.

Other Threads

1. Fun & games with PopupWindow

In my activity I'm experimenting to get an effect of a small button
floating over a list component in its bottom right corner. It seems
that there is no default view group component that would easily allow
for this. So I tried an approach of having a PopupWindow containing
the button rendered over the list. This is, roughly, the code I have
private void initButton() {
        View buttonView =
getLayoutInflater().inflate(R.layout.keyboard_button, null);
        buttonPopup = new PopupWindow(buttonView);
        final View container = findViewById(; //
root view
        final View listContainer = findViewById(; Runnable() { // showing in onCreate() or
onStart() impossible
            public void run() {
                buttonPopup.showAtLocation(container, Gravity.CENTER,
0, 0);
//                buttonPopup.update(listContainer, -1, -1);
//                buttonPopup.showAsDropdown(listContainer);

(where initButton is called in onStart()) Unfortunately, the
'showAtLocation' method does not work (the popup does not show in a
visible location). Surprisingly, when I uncomment the call to update
right after showAtLocation, or replace showAtLocation with the
commented out call to showAsDropdown, it works, i.e. displays the
button, but obviously not in the desired location (below the list
container, as opposed to within it, as the list container becomes the
anchor). I experimented with different values of Gravity (that's why
it's set to CENTER in the above code, originally it was RIGHT |
BOTTOM) and different values of x and y, but without success. I don't
know if it is relevant, but there is also a tab control involved in
this activity (the tabhost is the root view group). Any insights? Why
'showAtLocation' would not work? Perhaps there is a better way of
achieving what I want to achieve (i.e. without PopupWindow)?


2. NFC Intents: Reacting on specific NDEF types

Is it possible to restrict the type of tags an application is reacting

The intent filter used e.g. by the Tags application on the Nexus-S is
defined as
      <action android:name="android.nfc.action.TAG_DISCOVERED"/>
      <category android:name="android.intent.category.DEFAULT"/>
When a tag is detected, the user has to choose the application which
should handle the intent.

I would like to react depending on the NDEF type of the record, e.g.
my application should be started if the NDEF record is of type
EXTERNAL and if the uri is "".

Is such an extension of the intent filter possile?
If not, is it planned?



3. ListView in custom preference

4. How to draw button on canvas?

5. No <uses-feature name="vibration"/>; Do all android systems support vibration?

6. How can I android Market app for ginger bread

7. Isolated database tests