2

I am a new one in Android so please sorry for stupidity. Well my problem is in multiple layers -

I would like to combine two transparent ImageViews one above the other. This is similar to photoshops layers, what is the sample layers activity in android?

karthi B
  • 55
  • 5

4 Answers4

1

You can use a RelativeLayout for this.

The property android:layout_centerInParent If true, centers the child horizontally and vertically within its parent. [boolean]

Similarly there are properties like , android:layout_alignParentLeft,

android:layout_alignParentRight,

android:layout_alignParentTop,

android:layout_alignParentBottom.

Try these.

jency
  • 377
  • 2
  • 3
0

you can use the layer-list, for a full investigation, please refer to http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList

0

Already answered Overlapping Views in Android ? That should be all you need, using RelativeLayout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/layout"
>
<ImageView android:id="@+id/imageview1"
    android:background="#00000000"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/image1"
    />

 <ImageView android:id="@+id/imageview2"
    android:background="#00000000"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/image2"
    /> 

</RelativeLayout>

would be an example code for you.

Community
  • 1
  • 1
TryTryAgain
  • 7,632
  • 11
  • 46
  • 82
  • thanks.. i tried this code but still the screen is blank. should i add anything else in the code or only this xml file will do? – karthi B Jan 12 '12 at 11:36
  • You need 3 other files: image1, image2 respectively, and also your .java file that refers to the RelativeLayout. I'd also check the manifest, but that is an answer to a different question. Hope that's enough. – TryTryAgain Jan 12 '12 at 16:57
  • i added three images in drawable. then also it is not working. help me out. now my application has 3 images and this xml file in main.xml. – karthi B Jan 13 '12 at 09:06
0

Well its quite possible to do in android, but the thing is what actually you are going to do with that. you can give the same positions for both the images in layout now both will be overlapped and based on your condition or situation you can show and hide one another programatically. In the same way you can give multiple images overlapped on one another. Hope this will help you out to understand :)

Daud Arfin
  • 2,499
  • 1
  • 18
  • 37
  • thanks i tried it now am able to see two images. one above the other. i want to add motion event to the image in background. how can i do that ? can you help me? – karthi B Feb 02 '12 at 08:47