Layout Design[UI Design]
Each UI layout file must contain exactly one root element like textview or
or edittext or button, which must be a View or ViewGroup object. Once we defined
the root element, we can add additional layout objects or widgets as
child elements to gradually build a View hierarchy that defines our layout.
Example : The XML layout that uses a vertical LinearLayout to hold a
Button and a Edittext.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button" />
<EditText android:id="@+id/edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a EditText" />
</LinearLayout>
Example : The XML layout that uses a Horizontal Linearlayout to
hold a Edittext and a Button
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a EditText" />
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button" />
</LinearLayout>
Example : The XML layout that uses a vertical Relative to
hold a Edittext and a Button.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText android:id="@+id/edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a EditText" />
<Button android:id="@+id/button"
android:layout_below="@+id/edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button" />
</RelativeLayout>
Looper benefits and why we using looper in android?
Difference between Thread and process
Why we are using Async Task in android?