Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android stacked views

Tags:

android

The view that I would like to have would be shown in the figure.

example

like image 534
Gunslinger Avatar asked Sep 25 '11 06:09

Gunslinger


People also ask

Which layout is used for overlapping of views in android?

The easiest way to do it would be to have an AbsoluteLayout and then put the two images where you want them to be. You don't need to do anything special for the transparent png except having it added later to the layout.

How do I move one view to the top of another android?

Just in case if you want to place a view on top of a ButtonView then use this; android:elevation="7dp" for the view which needs to be placed on top of the button. Thanks. It worked, but also worked with 1dp up for me.

How do you overlap views in constraint layout?

Overlapping Views As you can see all you need to do is align the top and bottom of the circular image with the bottom of the main image and this puts the centre of the circle on the bottom of the square image.

What is FrameLayout?

FrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other.


1 Answers

For that 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:

For Example - 2: Superb 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>
like image 154
Paresh Mayani Avatar answered Oct 13 '22 22:10

Paresh Mayani