Layout alignment Query {Center Horizontal + Center Vertical} - android

Must be very simple to solve but I'm not able to solve this.
I want to align the "top image and log_in_box", so the whole thing appear in exact center (Horizontal+Vertical center) of the screen.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"
android:layout_gravity="center_vertical|center_horizontal">
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="#drawable/ic_launcher"
android:contentDescription="" />
<LinearLayout android:id="#+id/log_in_box" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="User ID"
android:inputType="text" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"
android:hint="Password" android:inputType="textPassword" />
<CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="true"
android:text="Remember Me" android:layout_marginTop="10dp" />
<Button android:id="#+id/log_in" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:text="Log In" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Current Look

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true" >
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="#drawable/ic_launcher"
android:contentDescription="" />
<LinearLayout android:id="#+id/log_in_box" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="User ID"
android:inputType="text" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"
android:hint="Password" android:inputType="textPassword" />
<CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="true"
android:text="Remember Me" android:layout_marginTop="10dp" />
<Button android:id="#+id/log_in" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:text="Log In" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

Try this.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:src="#drawable/ic_launcher"
android:contentDescription="" />
<LinearLayout android:id="#+id/log_in_box" android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="User ID"
android:inputType="text" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"
android:hint="Password" android:inputType="textPassword" />
<CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="true"
android:text="Remember Me" android:layout_marginTop="10dp" />
<Button android:id="#+id/log_in" android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:text="Log In" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription=""
android:src="#drawable/ic_launcher" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="User ID"
android:inputType="text" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Password"
android:inputType="textPassword" />
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:checked="true"
android:text="Remember Me" />
<Button
android:id="#+id/log_in"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Log In" />

Related

After adding a ScrollView, the the app title is no longer displayed

Hi in the below code i have a login layout in that contains email id and password are the attributes.
Now want to display my layout in landscape mode.because of that i just added scrollview.
Now my problem is after adding the scrollview to my layout "LOGIN" title not showing .
can any one please help me
<?xml version="1.0" encoding="utf-8"?>
<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:background="#1c1c1c">
<RelativeLayout
android:id="#+id/toolbarRel"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
android:layout_gravity="center_vertical"
android:background="#color/color_toolbar">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login"
android:textColor="#color/white"
android:textSize="#dimen/heading_font_size"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1c1c1c"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbarRel"
android:layout_centerInParent="true"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical"
android:paddingEnd="#dimen/activity_horizontal_margin"
android:layout_marginTop="20dp"
android:paddingStart="#dimen/activity_horizontal_margin">
<EditText
android:id="#+id/et_email"
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textfield_outer_box"
android:drawablePadding="10dp"
android:drawableStart="#drawable/img_email_icon"
android:drawableLeft="#drawable/img_email_icon"
android:ems="10"
android:hint="Email Id"
android:inputType="textEmailAddress"
android:paddingStart="10dp"
android:paddingEnd="10dp"/>
<EditText
android:id="#+id/et_pwd"
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/homogeneous_margin"
android:background="#drawable/textfield_outer_box"
android:drawablePadding="10dp"
android:drawableStart="#drawable/img_password_icon"
android:drawableLeft="#drawable/img_password_icon"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:paddingEnd="10dp"
android:paddingStart="10dp" />
<Button
android:id="#+id/btn_login"
style="#style/style_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/heterogenous_margin"
android:background="#drawable/login_button"
android:paddingBottom="#dimen/button_topbottom_padding"
android:text="#string/get_started" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/homogeneous_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password?"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:textSize="18sp"
android:textColor="#android:color/white"
android:id="#+id/txt_forgot_password"/>
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="#dimen/homogeneous_margin"
android:gravity="center"
android:text="Create Account"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/common_text"
android:layout_marginBottom="13dp"
android:text="or sign with"
android:visibility="gone"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="2"
android:visibility="visible">
<!--<com.facebook.login.widget.LoginButton-->
<!--android:id="#+id/login_button"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginBottom="8dp"-->
<!--android:layout_marginLeft="8dp"-->
<!--android:layout_margin="4dp"-->
<!--android:layout_paddinBottom="12dp"-->
<!--android:layout_paddingTop="12dp"-->
<!--android:gravity="center"-->
<!--android:layout_weight="1"-->
<!--/>-->
<!--<com.google.android.gms.common.SignInButton-->
<!--android:id="#+id/signin_button"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_centerInParent="true"-->
<!--android:layout_weight="1"/>-->
</LinearLayout>
</RelativeLayout>
Your title is not displaying because the height of your ScrollView is match_parent
So your RelativeLayout is hiding behind ScrollView
Just add android:layout_below="#id/toolbarRel" in your ScrollView
SAMPLE CODE
<?xml version="1.0" encoding="utf-8"?>
<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:background="#1c1c1c">
<RelativeLayout
android:id="#+id/toolbarRel"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_height"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical"
android:background="#color/color_toolbar">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/login"
android:textColor="#color/white"
android:textSize="#dimen/heading_font_size"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/toolbarRel"
android:background="#1c1c1c"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbarRel"
android:layout_centerInParent="true"
android:layout_marginTop="20dp"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical"
android:paddingStart="#dimen/activity_horizontal_margin"
android:paddingEnd="#dimen/activity_horizontal_margin">
<EditText
android:id="#+id/et_email"
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/textfield_outer_box"
android:drawableStart="#drawable/img_email_icon"
android:drawableLeft="#drawable/img_email_icon"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Email Id"
android:inputType="textEmailAddress"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<EditText
android:id="#+id/et_pwd"
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/homogeneous_margin"
android:background="#drawable/textfield_outer_box"
android:drawableStart="#drawable/img_password_icon"
android:drawableLeft="#drawable/img_password_icon"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<Button
android:id="#+id/btn_login"
style="#style/style_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/heterogenous_margin"
android:background="#drawable/login_button"
android:paddingBottom="#dimen/button_topbottom_padding"
android:text="#string/get_started" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/homogeneous_margin">
<TextView
android:id="#+id/txt_forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:text="Forgot Password?"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="#dimen/homogeneous_margin"
android:gravity="center"
android:text="Create Account"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<TextView
style="#style/common_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="13dp"
android:text="or sign with"
android:visibility="gone" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="2">
<!--<com.facebook.login.widget.LoginButton-->
<!--android:id="#+id/login_button"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="center_vertical"-->
<!--android:layout_marginBottom="8dp"-->
<!--android:layout_marginLeft="8dp"-->
<!--android:layout_margin="4dp"-->
<!--android:layout_paddinBottom="12dp"-->
<!--android:layout_paddingTop="12dp"-->
<!--android:gravity="center"-->
<!--android:layout_weight="1"-->
<!--/>-->
<!--<com.google.android.gms.common.SignInButton-->
<!--android:id="#+id/signin_button"-->
<!--android:layout_width="0dp"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_centerInParent="true"-->
<!--android:layout_weight="1"/>-->
</LinearLayout>
</RelativeLayout>
UPDATE
<?xml version="1.0" encoding="utf-8"?>
<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:background="#1c1c1c">
<RelativeLayout
android:id="#+id/toolbarRel"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:textColor="#android:color/white"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/toolbarRel"
android:layout_centerInParent="true"
android:background="#1c1c1c"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical"
android:paddingStart="#dimen/activity_horizontal_margin"
android:paddingEnd="#dimen/activity_horizontal_margin">
<EditText
android:id="#+id/et_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Email Id"
android:inputType="textEmailAddress"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<EditText
android:id="#+id/et_pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:paddingStart="10dp"
android:paddingEnd="10dp" />
<Button
android:id="#+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="get_started" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/txt_forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:gravity="center_vertical"
android:text="Forgot Password?"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/text_create_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="Create Account"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="13dp"
android:text="or sign with"
android:visibility="gone" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:visibility="visible"
android:weightSum="2">
</LinearLayout>
</RelativeLayout>

Why is my app rendering only one half of the page?

I have been trying to develop a form in android studio, and I am quite new to xml so not sure what I am doing wrong. Hopefully you can see from below, the preview shows as the boxes taking up basically the full page, however when I render it in a phone it only takes up half the page. Xml code is also below - any ideas would be greatly appreciated? Thanks
XML preview:
Rendered view:
XML Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/RelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:theme="#style/AppTheme">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/activity_horizontal_margin"
android:orientation="vertical">
<EditText
android:id="#+id/editText10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Date"
android:inputType="date" />
<EditText
android:id="#+id/editText8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Time"
android:inputType="time" />
<EditText
android:id="#+id/editText9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Location"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editText11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:drawable/editbox_background_normal"
android:ems="10"
android:hint="Tester Notes"
android:inputType="textMultiLine" />
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Show Notes at appointment" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Missed Appointment" />
<LinearLayout
android:id="#+id/Buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="#+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save Notes" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send Email" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/Name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="60dp"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:id="#+id/Date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Date"
android:inputType="date" />
</LinearLayout>
<LinearLayout
android:id="#+id/Time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Time"
android:inputType="time" />
</LinearLayout>
<LinearLayout
android:id="#+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Location"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:id="#+id/testernotes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editText11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:ems="10"
android:hint="Tester Notes"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:id="#+id/checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:text="CheckBox" />
</LinearLayout>
<LinearLayout
android:id="#+id/checkBox2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="CheckBox" />
</LinearLayout>
<LinearLayout
android:id="#+id/Buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:orientation="horizontal">
<Button
android:id="#+id/button3"
android:text="button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send Email" />
</LinearLayout>
</LinearLayout>
</ScrollView>
please try this xml
layout_weight and its usages was wrong in your xml ,while using layout_weight you have use android:layout_width = "0dp" as per the orientation,
for more info refer
[https://developer.android.com/guide/topics/ui/layout/linear.html][1]
https://blog.stylingandroid.com/layout-weights-part-1/
What does android:layout_weight mean?
much easier implementation
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<LinearLayout
android:layout_margin="#dimen/activity_horizontal_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editText10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Date"
android:inputType="date" />
<EditText
android:id="#+id/editText8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Time"
android:inputType="time" />
<EditText
android:id="#+id/editText9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Location"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editText11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="Tester Notes"
android:inputType="textMultiLine" />
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CheckBox" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CheckBox" />
<LinearLayout
android:id="#+id/Buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:orientation="horizontal">
<Button
android:id="#+id/button3"
android:text="button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send Email" />
</LinearLayout>
</LinearLayout>
</ScrollView>
MATCH_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any.
Replace this:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
With:
android:layout_width="match_parent"
android:layout_height="wrap_content"
into your LinearLayout.

Error:(143) Error parsing XML: not well-formed (invalid token)

I get this error only when I set the button text as "<< Previous" or "Next >>".
The interesting thing is that no error is shown when I set "<< Previous" as button text in a particular xml.
I have attached both the XML files:
XML File that shows error:
<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:background="#drawable/background111"
tools:context=".Register_Page2">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="30dp"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginTop="20dp"
android:text="* Required"
android:textColor="#color/Item_Red"></TextView>
<RelativeLayout
android:id="#+id/relativelayout_q1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/q4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Have you completed an IELTS examination? *"
android:textColor="#color/black"
android:textSize="23dp"></TextView>
<RadioGroup
android:id="#+id/radioGroup4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/q4"
android:layout_marginTop="10dp">
<RadioButton
android:id="#+id/radio_q4_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="YES" />
<RadioButton
android:id="#+id/radio_q4_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NO" />
<RadioButton
android:id="#+id/radio_q4_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CURRENTLY TRAINING FOR THE IELTS EXAM" />
</RadioGroup>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#android:color/darker_gray" />
<RelativeLayout
android:id="#+id/relativelayout_q2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/q5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Do you have a Graduate Degree or Master's Diploma? *"
android:textColor="#color/black"
android:textSize="23dp"></TextView>
<RadioGroup
android:id="#+id/radioGroup5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/q5"
android:layout_marginTop="10dp">
<RadioButton
android:id="#+id/radio_q5_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="YES" />
<RadioButton
android:id="#+id/radio_q5_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NO" />
<RadioButton
android:id="#+id/radio_q5_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="IN PROCESS" />
<RadioButton
android:id="#+id/radio_q5_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="JUST GRADUATED" />
</RadioGroup>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<Button
android:id="#+id/Previous2"
style="?attr/borderlessButtonStyle"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:text="<<Previous"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/Next2"
style="?attr/borderlessButtonStyle"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:text="Next>>"
android:textAllCaps="false"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
XML File which does not show the error:
<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:background="#drawable/background111"
tools:context=".Register_Page1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="30dp"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/t1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:padding="5dp"
android:text="Elite English Club Entry Assessment Form"
android:textColor="#color/black"
android:textSize="38dp"
android:typeface="sans" />
<TextView
android:id="#+id/t2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/t1"
android:gravity="center_horizontal"
android:text="This is our Form for students who are interested in joining our Elite English Club."></TextView>
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/t2"
android:layout_gravity="left"
android:layout_marginTop="20dp"
android:text="* Required"
android:textColor="#color/Item_Red"></TextView>>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="#+id/usernameWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<EditText
android:id="#+id/Name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="What's your name? *"
android:inputType="textPersonName"
android:textColorHighlight="#fff" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/englishlevelWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/usernameWrapper"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/English_Level"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="What is your english level? *"
android:inputType="textMultiLine" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/reasonsWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/englishlevelWrapper"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/Reasons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:ems="10"
android:hint="Reasons for improving your English*"
android:inputType="textMultiLine" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<Button
android:id="#+id/Next1"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
style="?attr/borderlessButtonStyle"
android:textColor="#ffffff"
android:text="Next>>"
android:textAllCaps="false" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
Try this code
<Button
android:id="#+id/Previous2"
style="?attr/borderlessButtonStyle"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:text="<< Previous"
android:textAllCaps="false"
android:textColor="#ffffff" />
<Button
android:id="#+id/next"
style="?attr/borderlessButtonStyle"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:text="Next >>"
android:textAllCaps="false"
android:textColor="#ffffff" />
Characters < and > need to be escaped in xml files.
You can escape < with < or < and > with > or >.

ScrollView Not Working(It's Not Scrolling the layout)

I am new to Android and working on a App and stuck here on ScrollView. I have tried width and height "match parent" but still not working. I am posting my code. I have wasted more than an hour on this. Thanks in advance.
Here is my XML:
<?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:weightSum="1"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.02"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="20dp"
android:text="Marketing"
android:textColor="#color/black"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_header"
android:layout_weight="0.02"
android:background="#color/light_blue"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="Register Here"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="0.04"
android:orientation="vertical">
<EditText
android:id="#+id/edit_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name*"
android:inputType="text" />
<EditText
android:id="#+id/edit_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Email*"
android:inputType="text" />
<EditText
android:id="#+id/edit_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Password*"
android:inputType="text" />
<EditText
android:id="#+id/edit_cnfrm_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Confirm Password*"
android:inputType="text" />
<Button
android:id="#+id/btn_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_bg"
android:padding="15dp"
android:text="Register"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_forgot_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Forgot/Reset Password"
android:textColor="#color/light_blue" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:weightSum="1"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<Button
android:id="#+id/btn_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GOOGLE"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="15sp"
android:layout_marginRight="5dp"
android:background="#color/red"
android:layout_weight="0.5"/>
<Button
android:id="#+id/btn_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FACEBOOK"
android:textColor="#color/white"
android:background="#color/fb_blue"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:textSize="15sp"
android:layout_weight="0.5"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
set lay out weight to scroll view like
<ScrollView
android:layout_weight="0.96"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Can't get to the bottom of the content with my scrollview

I have my xml file. It is a RelativeLayout with a ScrollView and inside the ScrollView I have LinearLayout and many more. The problem is that I can't reach the end of the view, as you can see it end with a "Sign Up" button... But my view is cut by the scroll and I can just see the middle of the button, the other middle is off screen.
So, any suggestions for how can I fix this? How can I work with the ScrollView so it wraps all of my content...
Check it:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_signup"
android:orientation="vertical"
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=".SignUp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:background="#xml/signup_round">
<LinearLayout
android:layout_width="260dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#xml/border_lines"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/new_signup" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="#string/signup"
android:textColor="#color/colorRB"
android:textSize="26sp"
android:textStyle="bold" />
</LinearLayout>
<EditText
android:id="#+id/first_name_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="-25dp"
android:hint="#string/first_name"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/last_name_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/last_name"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/email_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/email"
android:inputType="textEmailAddress"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/email_confirmation_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/email_confirmation"
android:inputType="textEmailAddress"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/password_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/password"
android:inputType="textPassword"
android:textColor="#color/colorRB" />
<EditText
android:id="#+id/password_confirmation_EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:hint="#string/password_confirmation"
android:inputType="textPassword"
android:textColor="#color/colorRB" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#xml/border_lines"
android:text="#string/sex"
android:textColor="#color/colorRB"
android:textSize="26sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/sex_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-25dp"
android:entries="#array/sex_array" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#xml/border_lines"
android:text="#string/brithday"
android:textColor="#color/colorRB"
android:textSize="26sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-35dp"
android:orientation="horizontal">
<Button
android:id="#+id/birthdayBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="#color/fbutton_color_transparent"
android:onClick="showDatePickerDialog"
android:text="#string/birthdayBtn"
android:textAllCaps="false"
android:textColor="#color/colorRB" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/dateSelectedTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="--/--/--"
android:textColor="#color/colorRB"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="5dp"
android:text="#string/terms_conditions"
android:textColor="#color/colorRB"
android:textStyle="bold" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:background="#xml/button_round"
android:onClick=""
android:text="#string/signup"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick=""
android:src="#drawable/close_signup" />
</RelativeLayout>

Categories

Resources