开发者

How to display the image inside the android widget background?

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 开发者_StackOverflowmuch 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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜