android_learners_hub
Example
to Design Relative Layout :-
Example
to Design Relative Layout :-
Whole Layout Code :
activity_main.xml
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
//starting relative layout
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter your details here.."
android:textAlignment="center"
android:textSize="50sp"
android:layout_marginBottom="12sp"
/>
<EditText
android:id="@+id/name"
android:layout_width="200sp"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:hint="Name"
/>
// create an edit text for Roll number which will take only
// INTIGER AS INPUT
<EditText
android:id="@+id/roll_number"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Roll Number"
android:layout_below="@+id/text"
android:layout_toRightOf="@+id/name"
/>
<EditText
android:layout_width="200sp"
android:layout_height="wrap_content"
android:id="@+id/Class"
android:layout_below="@id/name"
android:hint="Class"
/>
<EditText
android:id="@+id/Aim"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/roll_number"
android:hint="Aim"
android:layout_toRightOf="@+id/name"
/>
// Insert an imageview
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="200sp"
android:src="@drawable/ic_launcher_background"
android:layout_below="@id/Aim"
android:layout_marginTop="12sp"
/>
<Button
android:id="@+id/back_button"
android:layout_marginTop="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back"
android:layout_below="@+id/image"
/>
<Button
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:layout_marginTop="12sp"
android:layout_below="@id/image"
android:layout_alignParentRight="true"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/next"
android:layout_marginTop="20sp"
android:text="SUBMIT"
android:textSize="20sp"
android:background="@color/colorAccent"
/>
</RelativeLayout>// close relative layout
👍👍👍 Great Work
ReplyDeleteGud work keep it up
ReplyDelete