How place overlay imageview on two layouts?

android overlay view programmatically
how to overlay one layout to another in android

I want to build the following screen which contains app logo, success/failure icon image, information message and ok button.

Here this the code. I am using linear layout to achieve this.

<LinearLayout
android:id="@+id/statusLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@android:color/white"
android:weightSum="2"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
    android:id="@+id/statusTopRelativeLayout"
    android:background="@android:color/holo_blue_bright"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:orientation="vertical"
    android:layout_weight="1">
    <ImageView
        android:id="@+id/client_logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@string/no_image_description"
        android:src="@drawable/client_logo"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"/>
</RelativeLayout>
<RelativeLayout
    android:id="@+id/statusBottomRelativeLayout"
    android:background="@android:color/holo_blue_light"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <TextView
        android:id="@+id/statusText"           
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:text="@string/statusText"
        android:textSize="50sp"/>
    <Button
        android:id="@+id/btnOk"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/statusText"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"            
        android:clickable="true"
        android:focusable="true"
        android:onClick="goToHomeScreen"
        android:paddingBottom="15dp"
        android:paddingTop="15dp"
        android:text="@string/ok"
        android:textColor="#ffffff"
        android:textSize="40sp"/>
</RelativeLayout>

How to place success/failure icon image on top of the two layouts?

Try this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/nilu"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@color/colorPrimary"
            android:orientation="vertical"
            android:paddingBottom="30dp">


            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="NILU" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="NILU" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="NILU" />


        </LinearLayout>

        <LinearLayout
            android:id="@+id/nilu2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/nilu"
            android:layout_weight="1"
            android:background="@color/colorAccent"
            android:orientation="vertical">


            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="NILU" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="NILU" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="NILU" />

        </LinearLayout>
    </LinearLayout>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:src="@mipmap/ic_launcher_round" />


    </RelativeLayout>


</RelativeLayout>

OUTPUT

How to overlay an imageView on another imageView in Android in a , This example demonstrates how do I overlay two images In Android setContentView(R.layout.activity_main); imageView = findViewById(R.id. This example demonstrates how do I overlay two images In Android to set an ImageView. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml.

You can use constraint to make it easy

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.constraint.Guideline
        android:id="@+id/center"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.5"/>

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@id/center"
        android:background="#ffffff"/>

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="@id/center"
        app:layout_constraintBottom_toBottomOf="parent"
        android:background="#00ffff"/>

    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#ff8801"
        app:layout_constraintTop_toTopOf="@id/center"
        app:layout_constraintBottom_toBottomOf="@id/center"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

</android.support.constraint.ConstraintLayout>

Output:

How to overlay two images in Android to set an ImageView?, See that pic? how it's positioned over the two different parts of the screen, the cover image above and the other layout below. Picture this: Two linear layout, the​  First add the two ImageViews as children of a RelativeLayout. To position it relative to the edges or to another view, use the various align settings of the ImageView. To position it at a specific coordinate, use getLayoutParams function to get the current layout parameters of the view to be positioned.

How to position an imageView right at the intersection line of two , place both images in a relative layout first determine the image you want to put behind the green circle I recommend you use a frame with these two images. How to place textview text above imageview image without programmatically method. TextView text can be easily replaceable above imageview image using layout xml file in relative layout. So here is the complete step by step tutorial for Android overlay textview over imageview example via xml. Note : Put image inside drawable-hdpi folder. Download sample image from below and copy into drawable-hdpi folder.

‍ ‍ 🧚 Android - ImageView overlay another ImageView, Now, I want to display my circular ImageView centered and half-overlapping the top boundary of the ConstraintLayout which is the root Layout of my Fragment  Use a Canvas and draw the overlay icon on to the existing bitmap; Use a Layout and overlay the icon as needed. The first approach works, but leaves the bitmap with the image embedded in it permanetly, meaning if you want to have a toggle you have to redraw the bitmap again and display it without it.

How to place ImageView half overlapped on top boundary of , It has to be done with custom CSS codes. Implementation: We will create a layout with 2 rows - one below other. Padding will represent some  Overlap view by putting another view above in RelativeLayout android Juned Mughal January 12, 2016 March 29, 2016 Android Examples Tutorials Replacing TextView text over imageview using layout xml file.

How to Overlap an Image Between Two Sections, Insert · Contacts. Enums. Layout.Alignment · TextUtils.TruncateAt. android.text.​format ImageView. Kotlin |Java. public class ImageView If the view has no overlapping rendering, the view can draw each primitive 1) set adjustViewBounds to true 2) set maxWidth and maxHeight to 100 3) set the height  Overlay one picture on another picture online Select two pictures on your computer or phone and then click OK button at the bottom of this page. All other settings already installed by default.

Comments
  • Add the 2 layouts inside a Linear (vertical) layout. Then add this Linear layout inside a RelativeLayout along with the image.. Then place the Linear layout and the image on the center of the RelativeLayout. The order you place the items in the RelativeLayout matters on which item will be on top of the other (like z-axis).
  • thanks, @Nilesh Rathod with minor changes to your solution I am done my changes.