Android ScrollView not working properly when use toolbar - android

I developed an android application in which the scroll-view is not scrolling.. I am posting the code here pls check and if found any error pls help.. Here I used RelativeLayout as root and then Scroll-view and Relative Layout inside the scroll-view and ... Edit text ans Spinner inside relative layout... but this is not scrolling up..
This is my XML :-
<?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="#android:color/white">
<LinearLayout
android:id="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="#+id/tool_bar"
layout="#layout/app_bar" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none"
android:layout_above="#+id/btnAccept"
android:layout_below="#+id/ll1"
>
<RelativeLayout
android:id="#+id/rel_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TextView
android:id="#+id/txvPanmain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="WANT TO GET IN TOUCH WITH US?"
android:textColor="#131517"
android:textSize="18sp"
android:textStyle="bold" />
<android.support.design.widget.TextInputLayout
android:id="#+id/floatedtFullName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txvPanmain"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/edtFullName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:focusable="true"
android:hint="Full Name"
android:inputType="textCapSentences"
android:textColor="#android:color/black"
android:textColorHint="#ff0000"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="#+id/spinCountry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/floatedtFullName"
android:layout_marginTop="15dp"
android:entries="#array/country"
android:prompt="#string/addressProof" />
<View
android:id="#+id/vspincountry"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/spinCountry"
android:layout_marginTop="2dp"
android:background="#000000" />
<Spinner
android:id="#+id/spinCity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/vspincountry"
android:layout_marginTop="15dp"
android:entries="#array/country"
android:prompt="#string/addressProof" />
<View
android:id="#+id/vspincity"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/spinCity"
android:layout_marginTop="2dp"
android:background="#000000" />
<android.support.design.widget.TextInputLayout
android:id="#+id/float_edit_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/vspincity"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/edtEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:focusable="true"
android:hint="Email id"
android:inputType="textEmailAddress"
android:textColor="#android:color/black"
android:textColorHint="#A4A4A4"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/float_edit_mobileno"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/float_edit_email"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/edtMobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:focusable="true"
android:hint="Mobile no."
android:inputType="phone"
android:maxLength="10"
android:textColor="#android:color/black"
android:textColorHint="#A4A4A4"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="#+id/spinFeedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/float_edit_mobileno"
android:layout_marginTop="10dp"
android:entries="#array/country"
android:prompt="#string/addressProof" />
<View
android:id="#+id/vspinFeedback"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/spinFeedback"
android:layout_marginTop="2dp"
android:background="#000000" />
<android.support.design.widget.TextInputLayout
android:id="#+id/float_edit_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/vspinFeedback"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/edtComments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:focusable="true"
android:inputType="text"
android:hint="Comments"
android:lines="3"
android:maxLines="3"
android:textColor="#android:color/black"
android:textColorHint="#A4A4A4"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/btnAccept"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/red"
android:layout_alignParentBottom="true"
android:padding="5dp"
android:text="SUBMIT"
android:textColor="#color/white_color"
android:textSize="20sp"
android:textStyle="normal" />
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
This is my app_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:paddingTop="#dimen/app_bar_top_padding"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/Base.ThemeOverlay.AppCompat.Dark.ActionBar">
<TextView
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="22sp"
android:textColor="#android:color/white"
android:textStyle="bold"
android:text="Toolbar Title" />
</android.support.v7.widget.Toolbar>

Your ScrollView has to be a defined height. Try match_parent instead of wrap_content. When a ScrollView wraps its contents there is nothing beeing clipped of you might be able to scroll to.

Related

LinearLayout not scrolling when keyboard is appearing

I am facing a problem with ScrollView. When the keyboard is appearing, scrollview is not scrolling till the end of the view.
Here is my layout xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:text="Add Member"
android:textColor="#FFF"
android:textSize="#dimen/heading_text_size"
android:background="#color/heading"
android:gravity="center"
android:padding="10dp"
android:layout_height="?attr/actionBarSize"/>
<ScrollView
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<EditText
android:id="#+id/search_member_number"
android:layout_width="match_parent"
android:hint="Enter mobile number"
android:layout_weight="3"
android:inputType="phone"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/searchExistingUserButton"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:text="Search"
android:textAllCaps="false"
android:background="#FF9800"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<EditText
android:id="#+id/txtUsername"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:hint="Enter member name"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtAddress"
android:layout_width="match_parent"
android:hint="Address"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtEmail"
android:layout_width="match_parent"
android:hint="Email"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtContact"
android:layout_width="match_parent"
android:hint="Mobile No"
android:inputType="phone"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtReferredBy"
android:layout_width="match_parent"
android:hint="Referred by"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<AutoCompleteTextView
android:id="#+id/txtKittyGroups"
android:layout_width="match_parent"
android:hint="Enter kitty group name"
android:layout_margin="10dp"
android:layout_weight="8"
android:layout_gravity="center"
android:textSize="#dimen/admin_setup_buttons_text_size"
android:textColor="#000"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtRepeat"
android:layout_width="match_parent"
android:hint="Enter repeat number"
android:layout_margin="10dp"
android:inputType="number"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/createUserButton"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:text="Create Member"
android:textAllCaps="false"
android:background="#BBDEFB"
android:layout_margin="10dp"
android:padding="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
I have seen several posts in stackoverflow, but unfortunately none is working. What could be the possible solution?
Thanks in advance.
I think the problem is causing by adjustPan . Where adjust Pan does not resize the window, it pans the view so that whatever has focus is never obscured by the soft keyboard.
Add this to your AndroidManifest.xml . This might do the trick.
Example:
<activity android:name="YourActivity"
android:windowSoftInputMode="adjustResize" />
you need to add <Space/> and
android:layout_height="100dp"
give height static which you want.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:text="Add Member"
android:textColor="#FFF"
android:textSize="#dimen/heading_text_size"
android:background="#color/heading"
android:gravity="center"
android:padding="10dp"
android:layout_height="?attr/actionBarSize"/>
<ScrollView
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<EditText
android:id="#+id/search_member_number"
android:layout_width="match_parent"
android:hint="Enter mobile number"
android:layout_weight="3"
android:inputType="phone"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/searchExistingUserButton"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:text="Search"
android:textAllCaps="false"
android:background="#FF9800"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<EditText
android:id="#+id/txtUsername"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:hint="Enter member name"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtAddress"
android:layout_width="match_parent"
android:hint="Address"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtEmail"
android:layout_width="match_parent"
android:hint="Email"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtContact"
android:layout_width="match_parent"
android:hint="Mobile No"
android:inputType="phone"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtReferredBy"
android:layout_width="match_parent"
android:hint="Referred by"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<AutoCompleteTextView
android:id="#+id/txtKittyGroups"
android:layout_width="match_parent"
android:hint="Enter kitty group name"
android:layout_margin="10dp"
android:layout_weight="8"
android:layout_gravity="center"
android:textSize="#dimen/admin_setup_buttons_text_size"
android:textColor="#000"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/txtRepeat"
android:layout_width="match_parent"
android:hint="Enter repeat number"
android:layout_margin="10dp"
android:inputType="number"
android:layout_height="wrap_content"/>
<Button
android:id="#+id/createUserButton"
android:layout_width="wrap_content"
android:layout_gravity="right"
android:text="Create Member"
android:textAllCaps="false"
android:background="#BBDEFB"
android:layout_margin="10dp"
android:padding="10dp"
android:layout_height="wrap_content"/>
<Space
android:layout_width="match_parent"
android:layout_height="100dp" />
</LinearLayout>
</ScrollView>
</LinearLayout></LinearLayout>
Use this in your layout:
android:layout_marginBottom="16dp"

android - Adjust resize and scrollview not working with edittext

I have this form and when the soft keyboard is open, the screen does not resize and dont make scroll on it.
I really want to know why. Why my view does not scroll? Why does not resize?
This is my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
>
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="#android:color/transparent"
android:visibility="invisible"
app:navigationIcon="#drawable/ic_left_arrow"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<ImageView
android:id="#+id/imageView9"
android:layout_width="180dp"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/toolbar"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="10dp"
android:src="#drawable/logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView9"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignStart="#+id/imageView9"
android:layout_below="#+id/imageView9"
android:layout_marginLeft="15dp"
android:paddingBottom="6dp"
android:text="OFERTAR OU \nSIMULAR LANCE"
android:textColor="#eb262a"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/livre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Lance Livre" />
<RadioButton
android:id="#+id/fixo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Lance Fixo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout2"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Percentual do lance">
<EditText
android:id="#+id/percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/textView12"
android:layout_toStartOf="#+id/textView12"
android:ems="10"
android:inputType="numberDecimal"
android:nextFocusDown="#+id/value"
android:textSize="14dp" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="#+id/textView12"
android:layout_width="25dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="%"
android:textColor="#000"
android:textSize="16dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Valor do lance">
<EditText
android:id="#+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:textSize="14dp" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="Número do Protocolo">
<EditText
android:id="#+id/protocol"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:textSize="14dp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="10">
<Button
android:id="#+id/limpar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Limpar"
android:textColor="#ffffff"
android:visibility="visible" />
<Button
android:id="#+id/simular"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Simular"
android:textColor="#ffffff"
android:visibility="visible" />
<Button
android:id="#+id/registrar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Registrar"
android:textColor="#ffffff"
android:visibility="gone" />
</LinearLayout>
<TextView
android:id="#+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="20dp"
android:text="Lance Fixo é definido em 30%"
android:textAlignment="center"
android:textColor="#000"
android:textSize="16sp"
android:visibility="gone" />
</LinearLayout>
</ScrollView>
</LinearLayout>
I already tried set match_parent to scrollview.
And I have this in my manifest android:windowSoftInputMode="stateAlwaysHidden|adjustResize".
If you are using "FULLSCREEN" theme for your application or activity then the "RESIZE" functionality will not work, you should use "NoTitleBar" theme without "FULLSCREEN".
It will work 100%.
And you should use "RelativeLayout" in place of parent layout(main linearlayout).
I found the problem. I'm using <item name="android:windowFullscreen">true</item>
and when the fullscreen flags are actived, the resize dont work.
If you want to resize the activity when the keyboard pops up you need to specify a line of code in manifest file inside activity tag :
android:windowSoftInputMode="adjustResize"
Refer this link for more details : https://developer.android.com/training/keyboard-input/visibility.html
You can even try to adjust screen in activity put the below code in you activity onCreate method:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Hope this should help!!
add this line to activity which you want to resize on opening soft keyboard:
android:windowSoftInputMode="adjustResize"
UPDATE POST:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="#android:color/transparent"
android:visibility="invisible"
app:navigationIcon="#drawable/ic_left_arrow"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<ImageView
android:id="#+id/imageView9"
android:layout_width="180dp"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/toolbar"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="10dp"
android:src="#drawable/logo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView9"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignStart="#+id/imageView9"
android:layout_below="#+id/imageView9"
android:layout_marginLeft="15dp"
android:paddingBottom="6dp"
android:text="OFERTAR OU \nSIMULAR LANCE"
android:textColor="#eb262a"
android:textSize="20sp"
android:textStyle="bold"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/livre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Lance Livre"/>
<RadioButton
android:id="#+id/fixo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Lance Fixo"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout2"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Percentual do lance">
<EditText
android:id="#+id/percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/textView12"
android:layout_toStartOf="#+id/textView12"
android:ems="10"
android:inputType="numberDecimal"
android:nextFocusDown="#+id/value"
android:textSize="14dp"/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="#+id/textView12"
android:layout_width="25dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="%"
android:textColor="#000"
android:textSize="16dp"
android:textStyle="bold"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Valor do lance">
<EditText
android:id="#+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:textSize="14dp"/>
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="Número do Protocolo">
<EditText
android:id="#+id/protocol"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:textSize="14dp"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="10">
<Button
android:id="#+id/limpar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Limpar"
android:textColor="#ffffff"
android:visibility="visible"/>
<Button
android:id="#+id/simular"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Simular"
android:textColor="#ffffff"
android:visibility="visible"/>
<Button
android:id="#+id/registrar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Registrar"
android:textColor="#ffffff"
android:visibility="gone"/>
</LinearLayout>
<TextView
android:id="#+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="20dp"
android:text="Lance Fixo é definido em 30%"
android:textAlignment="center"
android:textColor="#000"
android:textSize="16sp"
android:visibility="gone"/>
</LinearLayout>
</ScrollView>
</LinearLayout>

Edit Text does not stretch automatically when Landscape Android

I am really new in Android programming. I try to design chat layout but i found some problem of layout design. Why the Edit Text layout doesn't stretch automatically in landscape mode?
Here is the preview
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/myappbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom">
<include
layout="#layout/input_message_area"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:layout_weight="1"
android:gravity="bottom" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/myappbar"
android:layout_marginTop="?attr/actionBarSize"
android:layout_marginBottom="75dp"
android:background="#63DDEC"
android:paddingLeft="5dip"
android:paddingTop="0dip"
android:paddingRight="5dip"
android:paddingBottom="1dip">
<ListView
android:id="#+id/lv_chat_story"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:divider="#color/colorTransparent"
android:dividerHeight="0dp" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
and this is for input_message_area.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#63DDEC"
android:gravity="bottom"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/inputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/rounded_corner_a"
android:layout_marginLeft="10dp"
android:layout_marginTop="1dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="5dp"
android:padding="3dp">
<Button
android:id="#+id/buttonEmoji"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:background="#drawable/smile_center" />
<EditText
android:id="#+id/chat_edit_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="0dp"
android:scrollHorizontally="false"
android:layout_toRightOf="#id/buttonEmoji"
android:hint="Type a message"
android:maxLines="4"
android:singleLine="false"
android:inputType="textCapSentences"
android:textSize="18sp"
android:paddingLeft="4dp"/>
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/chat_edit_text1"
android:background="#drawable/camera_center"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_main"
android:layout_toRightOf="#id/inputLayout"
android:layout_alignBaseline="#+id/inputLayout"
android:layout_alignBottom="#+id/inputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp"
android:layout_marginLeft="-10dp"
android:layout_marginRight="16dp"
android:clickable="true"
android:src="#drawable/send_center"
app:backgroundTint="#color/colorPrimary"
app:layout_anchor="#id/inputLayout"
app:layout_anchorGravity="bottom|right" />
</LinearLayout>
Thank you.
Add weight to RelativeLayout.
please find my code. This will help you.
input_message_area.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#63DDEC"
android:gravity="bottom"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/inputLayout"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#drawable/rounded_corner_a"
android:layout_marginLeft="10dp"
android:layout_marginTop="1dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="5dp"
android:padding="3dp">
<Button
android:id="#+id/buttonEmoji"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:background="#drawable/smile_center" />
<EditText
android:id="#+id/chat_edit_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="0dp"
android:scrollHorizontally="false"
android:layout_toRightOf="#id/buttonEmoji"
android:hint="Type a message"
android:layout_marginRight="50dp"
android:maxLines="4"
android:singleLine="false"
android:inputType="textCapSentences"
android:textSize="18sp"
android:paddingLeft="4dp"/>
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/camera_center"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_main"
android:layout_toRightOf="#id/inputLayout"
android:layout_alignBaseline="#+id/inputLayout"
android:layout_alignBottom="#+id/inputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp"
android:layout_marginLeft="-10dp"
android:layout_marginRight="16dp"
android:clickable="true"
android:src="#drawable/send_center"
app:backgroundTint="#color/colorPrimary"
app:layout_anchor="#id/inputLayout"
app:layout_anchorGravity="bottom|right" />
Give android:layout_width="match_parent" to your Edit Text.
<EditText
android:id="#+id/chat_edit_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="0dp"
android:scrollHorizontally="false"
android:layout_toRightOf="#id/buttonEmoji"
android:hint="Type a message"
android:maxLines="4"
android:singleLine="false"
android:inputType="textCapSentences"
android:textSize="18sp"
android:paddingLeft="4dp"/>
Change EditText width from wrap_content to match_parent.
input_message_area.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#63DDEC"
android:gravity="bottom"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/inputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/rounded_corner_a"
android:layout_marginLeft="10dp"
android:layout_marginTop="1dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="5dp"
android:padding="3dp">
<Button
android:id="#+id/buttonEmoji"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:background="#drawable/smile_center" />
<EditText
android:id="#+id/chat_edit_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="0dp"
android:scrollHorizontally="false"
android:layout_toRightOf="#id/buttonEmoji"
android:hint="Type a message"
android:maxLines="4"
android:singleLine="false"
android:inputType="textCapSentences"
android:textSize="18sp"
android:paddingLeft="4dp"/>
<Button
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/chat_edit_text1"
android:background="#drawable/camera_center"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab_main"
android:layout_toRightOf="#id/inputLayout"
android:layout_alignBaseline="#+id/inputLayout"
android:layout_alignBottom="#+id/inputLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp"
android:layout_marginLeft="-10dp"
android:layout_marginRight="16dp"
android:clickable="true"
android:src="#drawable/send_center"
app:backgroundTint="#color/colorPrimary"
app:layout_anchor="#id/inputLayout"
app:layout_anchorGravity="bottom|right" />
</LinearLayout>

Coordinator Layout View prevents other layouts from being displayed?

I have a CoordinatorLayout used for displaying an AppBarLayout. However, the issue is that my RelativeLayout and LinearLayout are hidden by my ListView. Moreover, my ListView does not show fully: rather, part of the first ListView element is cut off but I can scroll through and see the rest. Below was my attempt:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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="match_parent" android:fitsSystemWindows="true"
xmlns:fresco="http://schemas.android.com/tools"
android:id="#+id/comments_coordinator_layout">
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/comments_appbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_below="#id/comments_coordinator_layout"
android:id="#+id/view_post"
android:layout_width="match_parent"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:orientation="horizontal"
android:layout_height="175dp"
android:background="#e6e6e6">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_marginTop="15dp"
android:id="#+id/poster_picture"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_marginLeft="10dp"
fresco:placeholderImage="#mipmap/blank_prof_pic"
fresco:roundedCornerRadius="5dp"
/>
<TextView
android:layout_marginLeft="5dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="#id/poster_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:id="#+id/poster_name"/>
<TextView
android:layout_alignParentRight="true"
android:layout_marginTop="15dp"
android:layout_toRightOf="#id/poster_name"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:id="#+id/post_date"/>
<TextView
android:layout_marginLeft="5dp"
android:layout_toRightOf="#id/poster_picture"
android:layout_below="#id/poster_name"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/view_status" />
</RelativeLayout>
<ListView
android:id="#+id/lv_comments_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/send_message"
android:layout_below="#id/view_post">
</ListView>
<LinearLayout
android:id="#+id/send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<EditText
android:id="#+id/write_comment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="5"
android:gravity="top|left"
android:hint="Comment back!"
android:inputType="textMultiLine"
android:background="#color/white"
android:scrollHorizontally="false" />
<Button
android:id="#+id/send_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:text="send"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
One thing I don't understand is why when I click on the design tab of my layout, it just seems like all my layouts overlap each other as opposed to displaying below each other. Furthermore, I don't see why the ListView is prioritized being shown over my LinearLayout and RelativeLayout. Is there any way I can get it so that I have the following structure from top to bottom: AppBarLayout -> RelativeLayout -> ListView -> LinearLayout. Any help would be appreciated. Thanks!
If it means anything, in my AndroidManifest, I have android:windowSoftInputMode="stateVisible"
Block quote
EDIT: this is an example of what I want to achieve
Edit: After taking some advice from tiny sunshine, here is what I have so far:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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="match_parent" android:fitsSystemWindows="true"
xmlns:fresco="http://schemas.android.com/tools"
android:id="#+id/comments_coordinator_layout">
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/comments_appbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_marginTop="?attr/actionBarSize"
android:layout_below="#id/comments_coordinator_layout"
android:id="#+id/view_post"
android:layout_width="match_parent"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:orientation="horizontal"
android:layout_height="175dp"
android:background="#e6e6e6">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_marginTop="15dp"
android:id="#+id/poster_picture"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_marginLeft="10dp"
fresco:placeholderImage="#mipmap/blank_prof_pic"
fresco:roundedCornerRadius="5dp"
/>
<TextView
android:layout_marginLeft="5dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="#id/poster_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:id="#+id/poster_name"/>
<TextView
android:layout_alignParentRight="true"
android:layout_marginTop="15dp"
android:layout_toRightOf="#id/poster_name"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:id="#+id/post_date"/>
<TextView
android:layout_marginLeft="5dp"
android:layout_toRightOf="#id/poster_picture"
android:layout_below="#id/poster_name"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/view_status" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_marginTop="225dp"
android:id="#+id/lv_comments_feed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/send_message">
</ListView>
<LinearLayout
android:id="#+id/send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<EditText
android:id="#+id/write_comment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="5"
android:gravity="top|left"
android:hint="Comment back!"
android:inputType="textMultiLine"
android:scrollHorizontally="false" />
<Button
android:id="#+id/send_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:text="send"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
EDIT: Issue with EditText. As you can see, the layout only shows the ListView when I click the EditText and hides everything including the ActionToolBar and Status Bar.
Edit: Showing Android Manifest
<activity android:name=".com.tabs.activity.Comments"
android:label="View Post"
android:theme="#style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".com.tabs.activity.news_feed"/>
</activity>
Edit: Suggestion by Tiny Sunlight:
<FrameLayout>
<ToolBar></ToolBar>
<Relative Layout as List header></RelativeLayout as ListHeader>
<ListView></ListView>
<LinearLayout for Edit Text></LinearLayout for EditText>
</FrameLayout>
Just add a ScrollView and set softInputMode to adjustResize.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:fitsSystemWindows="true"
android:layout_width="match_parent" android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<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="match_parent" android:fitsSystemWindows="true"
xmlns:fresco="http://schemas.android.com/tools"
android:id="#+id/comments_coordinator_layout">
<android.support.v7.widget.Toolbar
android:layout_alignParentTop="true"
android:id="#+id/comments_appbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
<RelativeLayout
android:layout_below="#id/comments_appbar"
android:id="#+id/view_post"
android:layout_width="match_parent"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:orientation="horizontal"
android:layout_height="175dp"
android:background="#e6e6e6">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_marginTop="15dp"
android:id="#+id/poster_picture"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_marginLeft="10dp"
fresco:placeholderImage="#mipmap/blank_prof_pic"
fresco:roundedCornerRadius="5dp"
/>
<TextView
android:layout_marginLeft="5dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="#id/poster_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:id="#+id/poster_name"/>
<TextView
android:layout_alignParentRight="true"
android:layout_marginTop="15dp"
android:layout_toRightOf="#id/poster_name"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:id="#+id/post_date"/>
<TextView
android:layout_marginLeft="5dp"
android:layout_toRightOf="#id/poster_picture"
android:layout_below="#id/poster_name"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/view_status" />
</RelativeLayout>
<ListView
android:id="#+id/lv_comments_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/send_message"
android:layout_below="#id/view_post">
</ListView>
<LinearLayout
android:id="#+id/send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<EditText
android:id="#+id/write_comment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="5"
android:gravity="top|left"
android:hint="Comment back!"
android:inputType="textMultiLine"
android:background="#color/white"
android:scrollHorizontally="false" />
<Button
android:id="#+id/send_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:text="send"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</RelativeLayout>
</ScrollView>

How to Place a FAB at the end of a View?

I'm trying to create a layout like below.
The problem is that the FAB is changing position in some devices because i have hardcoded the bottom margin.
I want the FAB as like in the below image.
PRESENT CODE
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/mlogin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="#+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="30dp"
android:elevation="8dp"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="30dp"
android:orientation="vertical">
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
android:src="#drawable/selfiel" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Login"
android:textAlignment="center"
android:textColor="#color/colorAccent"
android:textSize="22sp" />
<!-- Email Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
<!-- Password Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp">
<EditText
android:id="#+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/forgot"
android:layout_centerHorizontal="true"
android:layout_marginBottom="103dp"
android:src="#drawable/ic_done" />
<TextView
android:id="#+id/forgot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/submit"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:text="Forgot password?"
android:textColor="#color/white"
android:textSize="18sp" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:background="#color/colorAccent"
android:onClick="submit"
android:text="Sign Up"
android:textColor="#color/white"
android:textSize="18sp" />
</RelativeLayout>
</RelativeLayout>
You probably want to use the CoordinatorLayout.
The basic layout would be as follows:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/mlogin">
<android.support.v7.widget.CardView
android:id="#+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="30dp"
android:elevation="8dp"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30dp"
android:orientation="vertical">
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
android:src="#drawable/selfiel" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Login"
android:textAlignment="center"
android:textColor="#color/colorAccent"
android:textSize="22sp" />
<!-- Email Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
<!-- Password Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp">
<EditText
android:id="#+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom">
<TextView
android:id="#+id/forgot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Forgot password?"
android:textColor="#color/white"
android:textSize="18sp" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="Sign Up"
android:onClick="submit"
android:background="#color/colorAccent"
android:textColor="#color/white"
android:textSize="18sp"
android:layout_gravity="bottom|center_horizontal" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_done"
app:layout_anchor="#id/card"
app:layout_anchorGravity="bottom|center"/>
</android.support.design.widget.CoordinatorLayout>
The magic lines here are in the FloatingActionButton that say:
app:layout_anchor="#id/card"
app:layout_anchorGravity="bottom|center"
This essentially tells your layout that the FAB is related to the card, and that it should be positioned relative to the card (centered at the bottom).
You can find the CoordinatorLayout documentation here, and a pretty good tutorial here.
Best of luck!
use android:layout_gravity="bottom" instead Then adjust with margins if you want. so you can do this:
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/forgot"
android:layout_centerHorizontal="true"
android:layout_marginBottom="13dp"
android:layout_gravity="bottom"
android:src="#drawable/ic_done" />

Categories

Resources