Overlap view by putting another view above in RelativeLayout android

Replacing TextView text over imageview using layout xml file.

My in this tutorial i am placing a view widget using another view widget this type of functionality are called as overlapping views in android application. You can overlap any kind of widget using this tags attributes. So here is the complete step by step tutorial for Overlap view by putting another view above in RelativeLayout android.

android-project-download-code-button

How to Overlap view by putting another view above in RelativeLayout android.

Note : Copy image inside drawable-hdpi folder.

drawable hdpi folder

Download sample image view to test this project from below and put inside drawable-hdpi folder.

sample_view_1
Code for MainActivity.java file.

package com.overlappingviews_android_examples.com;
import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 }
}

Code for activity_main.xml layout file.

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context="com.overlappingviews_android_examples.com.MainActivity" >

 <ImageView
 android:id="@+id/imageView1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal="true"
 android:layout_centerVertical="true"
 android:src="@drawable/sample_view_1" />

 <TextView
 android:id="@+id/textView1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignLeft="@+id/imageView1"
 android:layout_centerVertical="true"
 android:text="Overlap view by putting another view above in RelativeLayout android"
 android:textAppearance="?android:attr/textAppearanceLarge"
 android:textColor="#ffffff"
 android:gravity="center" />

</RelativeLayout>

Screenshots:

Overlap view by putting another view above in RelativeLayout android

Click here to download Overlap view by putting another view above in RelativeLayout android project.

Leave a Reply

Your email address will not be published. Required fields are marked *