Set Align view to left side of relativelayout android using xml

Add button alignment on left side of activity screen inside relative layout.

Moving button to left side of activity screen is very easy with its given attributes because relative layout provides us so much different type of attributes and each attribute gives us more functionality. So here is he complete step by tutorial for Set Align view to left side of relativelayout android using xml.

android-project-download-code-button

How to Set Align view to left side of relativelayout android using xml.

Code for MainActivity.java file.

package com.viewalign_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.viewalign_android_examples.com.MainActivity"
 android:background="#a0fecc" >

 <Button
 android:id="@+id/button1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentLeft="true"
 android:layout_alignParentTop="true"
 android:text="Button" />

</RelativeLayout>

Screenshots:

Set Align view to left side of relativelayout android using xml

Click Here to download Set Align view to left side of relativelayout android using xml project.

Leave a Reply

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