Android platform with overlapping elements

Is it possible to have a view like the following with two custom views?

If I am going to use the canvas to draw things inside the view, is it possible to view the second view before the rest of the first view?

layout

+6
source share
2 answers

For this you can take FrameLayout .

For example - 1:

<FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:src="@drawable/icon" android:scaleType="fitCenter" android:layout_height="fill_parent" android:layout_width="fill_parent"/> <TextView android:text="Learn-Android.com" android:textSize="24sp" android:textColor="#000000" android:layout_height="fill_parent" android:layout_width="fill_parent" android:gravity="center"/> </FrameLayout> 

Update:

Example 2: An excellent example and Trick found here: http://www.curious-creature.org/2009/03/01/android-layout-tricks-3-optimize-part-1/

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="center" android:src="@drawable/golden_gate" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="20dip" android:layout_gravity="center_horizontal|bottom" android:padding="12dip" android:background="#AA000000" android:textColor="#ffffffff" android:text="Golden Gate" /> </FrameLayout> 
+8
source

Putting 2 custom views inside the relative layout will give what you showed in the image.

Yes, customview2 will be transparent in areas where you don't draw anything. To avoid this, you will need to set the background for this view.

0
source

Source: https://habr.com/ru/post/898004/


All Articles