Skip to content Skip to sidebar Skip to footer

Linear Layout:how To Fill The Whole Width Of Screen?

I've following layout file, which creates linear layout inside the relative layout. Copy

lines from parent RelativeLayout

<LinearLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:paddingTop="50px"android:background="#666666"android:orientation="horizontal"android:gravity="center_vertical"
    ><EditTextandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/newEvent"android:hint="Enter the Name of Event"android:layout_gravity="center_vertical" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Select Location"android:id="@+id/pickerButton"android:layout_gravity="center_vertical" /></LinearLayout>

Solution 2:

Change the top part of your Relative layout ot this:

<RelativeLayoutxmlns: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"tools:context=".MainActivity"android:background="#eeeeee">

EDIT:

Change your LinearLayout like this:

<RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:paddingTop="50px"android:background="#666666"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_centerVertical="true"android:orientation="horizontal"><EditTextandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/newEvent"android:hint="Enter the Name of Event" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Select Location"android:id="@+id/pickerButton" /></LinearLayout></RelativeLayout>

Solution 3:

In LinearLayout you are using android:paddingTop="50px". Instead use top and bottom padding 25px each.

Post a Comment for "Linear Layout:how To Fill The Whole Width Of Screen?"