views:

92

answers:

2

I have a widget layout xml which sets the src to the delivered android widget 4x1 frame image.Here is the widget layout code.

<?xml version="1.0" encoding="utf-8" ?> 
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"  
 android:id="@+id/tuwidget" android:layout_width="fill_parent" 
 android:layout_height="fill_parent">
<ImageView android:id="@+id/tuwidget_img_btn" 
 android:src="@drawable/widgetinitial" 
 android:layout_width="fill_parent" 
 android:layout_height="wrap_content" /> 
</AbsoluteLayout>

@drawable/widgetinitial holds the widgetinitial.png image example 4x1 at developer.android.com (AppWidget design guidelines).(4x1_Widget_Frame_Portrait.psd) What I am trying to do is display an image inside the delivered frame instead what happens is the frame image goes away and only the image I am trying to display shows up. How can I display the image inside the bounding box or the background? Any help is much appreciated.

Another question - I think I saw in a couple of forums AbsoluteLayout is a deprecated feature for Android 2.1 and above. Is that correct? and does using AbsoluteLayout throws any force close or other exceptions?

A: 

take a look at the end of page 2 of this pdf

Neuquino
Thanks for helping Neuquino. I read the whole pdf. Very Informative. Thanks.
Aakash
+1  A: 

AbsoluteLayout is deprecated. It doesn't throw any exceptions, but its generally a bad idea to use it because it is really hard to design a layout that will work on all screen sizes. There is generally a better way to do it using a different layout.

In your case, I don't follow exactly, but it sounds like you want to layer two widgets on top of each other? An image with a frame? To do so, I'd use a FrameLayout. This is designed for having multiple layers of images.

Common layout objects is also a good guide to the basic layout types.

Mayra
FrameLayout and ImageView together worked great...Thanks so much.
Aakash