1

In my project I have a menu. for design of menu i want to use gridView. for simplicity assume that this grid view has just one item. This item has two seperate images (background.png and news.png) and a text (for example "NEWS").

Is it possible to map news.png on background.png through xml or code?

Thanks for helping me.

3
  • u want to show two images one on another.... Commented Feb 29, 2012 at 5:11
  • Yes, I want to know is it practical?!!! Commented Feb 29, 2012 at 5:46
  • @Hesam did you find any solutions > Commented Nov 2, 2016 at 10:29

1 Answer 1

1

Yes you can always do that using FrameLayout in xml file,Like this.

<FrameLayout android:id="@+id/frameLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:id="@+id/imageView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/background"></ImageView> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_gravity="center" android:layout_height="wrap_content" android:src="@drawable/news"></ImageView> <TextView android:text="NEWS" android:id="@+id/textView1" android:layout_gravity="bottom|center_horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> </FrameLayout> 
Sign up to request clarification or add additional context in comments.

4 Comments

Or you could just set android:background property of parent layout (but it will stretch to layout size).
@Sver you mean to say take layout set background and take imageview and textview in that linear layout?..yeh that can work..might not look good programming but can achieve same outcome.
well, if background image is just simple background image without much details.. why not? In case of FrameLayout you need to take in account the sizes of images.
@MKJParekh I am using above code but When I get size of framelayout is return as the screen size , how to resolve it ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.