As Edittext it is not the only one in the group widget. With TextInputLayout the hint didn't work. Tell me is there any way else to summon help?
This is my layout:
<android.support.design.widget.TextInputLayout
android:id="#+id/til_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textColorHint="#color/colorTextHint">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/et_account_tint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorTextHint"
android:maxLines="1"
android:theme="#style/EditText"
android:textSize="16sp" />
<EditText
android:id="#+id/et_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:drawableRight="#mipmap/ic_selectcontact"
android:hint="#string/enter_phone_number_contact_name"
android:inputType="text"
android:maxLines="1"
android:textColorHint="#color/colorTextHint"
android:textSize="16sp"
android:theme="#style/EditText" />
<TextView
android:id="#+id/et_account_button"
android:layout_width="70dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#android:color/transparent"
android:onClick="#{presenter::onClick}"
android:textSize="16sp"
tools:ignore="LabelFor" />
</RelativeLayout>
</android.support.design.widget.TextInputLayout>
Do like this
<android.support.design.widget.TextInputLayout
android:id="#+id/til_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
app:hintEnabled="true" app:hintAnimationEnabled="false"
android:textColorHint="#color/colorTextHint">
<EditText
android:id="#+id/et_account_tint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorTextHint"
android:maxLines="1"
android:theme="#style/EditText"
android:textSize="16sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
app:hintEnabled="true"
app:hintAnimationEnabled="false"
android:textColorHint="#color/colorTextHint">
<EditText
android:id="#+id/et_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:drawableRight="#mipmap/ic_selectcontact" android:hint="#string/enter_phone_number_contact_name"
android:inputType="text"
android:maxLines="1"
android:textColorHint="#color/colorTextHint"
android:textSize="16sp"
android:theme="#style/EditText" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="#+id/et_account_button"
android:layout_width="70dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#android:color/transparent"
android:onClick="#{presenter::onClick}"
android:textSize="16sp"
tools:ignore="LabelFor" />
Related
stackoverflow.
I'm making a android input form view now, and have some issues in using scroll view.
First, please see my drawing.
design blueprint
I want to put some editTexts in views vertical, and put a submit button bottom of screen. But scrollView's child component's layout_height should be wrap_content, not match parent. So my submit button sets just below of last edit text. It would be easy if I could put some margin between last editText and button, but I can't. if I do that, I think layouts makes some problem in different device size.
This is my layout.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"
tools:context=".activity.ResendPwActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/title_layout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal">
<ImageButton
android:id="#+id/prev_btn"
android:layout_width="9dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:background="#drawable/prev"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/change_pw_string"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="-25dp"
android:gravity="center_vertical|center_horizontal"
android:text="#string/change_password"
android:textColor="#color/black"
android:textSize="17sp" />
</LinearLayout>
<View
android:id="#+id/line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/title_layout"
android:background="#dddddd" />
<TextView
android:id="#+id/current_pw_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/line"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="30dp"
android:text="#string/current_pw_string"
android:textColor="#color/black"
android:textSize="13sp" />
<EditText
android:id="#+id/current_pw_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/current_pw_label"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="15dp"
android:backgroundTint="#color/email_password_edittext_line_color_selector"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:textColor="#color/black"
android:textSize="17sp" />
<TextView
android:id="#+id/new_pw_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/current_pw_input"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="30dp"
android:text="#string/new_pw_string"
android:textColor="#color/black"
android:textSize="13sp" />
<EditText
android:id="#+id/new_pw_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/new_pw_label"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="15dp"
android:backgroundTint="#color/email_password_edittext_line_color_selector"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:textColor="#color/black"
android:textSize="17sp" />
<TextView
android:id="#+id/validate_pw_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/new_pw_input"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="30dp"
android:text="#string/validate_new_pw_string"
android:textColor="#color/black"
android:textSize="13sp" />
<EditText
android:id="#+id/validate_pw_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/validate_pw_label"
android:layout_marginBottom="30dp"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="15dp"
android:backgroundTint="#color/email_password_edittext_line_color_selector"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:textColor="#color/black"
android:textSize="17sp" />
<View
android:id="#+id/view_layout"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_below="#id/validate_pw_input" />
<Button
android:id="#+id/submit_btn"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_alignParentBottom="true"
android:background="#drawable/update_profile_btn_selector"
android:text="#string/update_change"
android:textColor="#color/white"
android:textSize="20sp" />
</RelativeLayout>
</ScrollView>
What should I do?
Try this
<?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"
tools:context=".activity.ResendPwActivity">
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/title_layout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal">
<ImageButton
android:id="#+id/prev_btn"
android:layout_width="9dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:background="#drawable/prev"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/change_pw_string"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="-25dp"
android:gravity="center_vertical|center_horizontal"
android:text="#string/change_password"
android:textColor="#color/black"
android:textSize="17sp" />
</LinearLayout>
<View
android:id="#+id/line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/title_layout"
android:background="#dddddd" />
<TextView
android:id="#+id/current_pw_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/line"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="30dp"
android:text="#string/current_pw_string"
android:textColor="#color/black"
android:textSize="13sp" />
<EditText
android:id="#+id/current_pw_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/current_pw_label"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="15dp"
android:backgroundTint="#color/email_password_edittext_line_color_selector"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:textColor="#color/black"
android:textSize="17sp" />
<TextView
android:id="#+id/new_pw_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/current_pw_input"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="30dp"
android:text="#string/new_pw_string"
android:textColor="#color/black"
android:textSize="13sp" />
<EditText
android:id="#+id/new_pw_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/new_pw_label"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="15dp"
android:backgroundTint="#color/email_password_edittext_line_color_selector"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:textColor="#color/black"
android:textSize="17sp" />
<TextView
android:id="#+id/validate_pw_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/new_pw_input"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="30dp"
android:text="#string/validate_new_pw_string"
android:textColor="#color/black"
android:textSize="13sp" />
<EditText
android:id="#+id/validate_pw_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/validate_pw_label"
android:layout_marginBottom="30dp"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="15dp"
android:backgroundTint="#color/email_password_edittext_line_color_selector"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:textColor="#color/black"
android:textSize="17sp" />
<View
android:id="#+id/view_layout"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_below="#id/validate_pw_input" />
<Button
android:id="#+id/submit_btn"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_alignParentBottom="true"
android:background="#drawable/update_profile_btn_selector"
android:text="#string/update_change"
android:textColor="#color/white"
android:textSize="20sp" />
</RelativeLayout>
</ScrollView>
your button should be at the bottom of screen for better responsive UI
and scrollview must only one child so you can not add button and relativelayout in scrollview at a time
<?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"
tools:context=".activity.ResendPwActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_above="#+id/submit_btn"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/title_layout"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal">
<ImageButton
android:id="#+id/prev_btn"
android:layout_width="9dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="16dp"
android:background="#drawable/prev"
tools:ignore="ContentDescription" />
<TextView
android:id="#+id/change_pw_string"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="-25dp"
android:gravity="center_vertical|center_horizontal"
android:text="#string/change_password"
android:textColor="#color/black"
android:textSize="17sp" />
</LinearLayout>
<View
android:id="#+id/line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/title_layout"
android:background="#dddddd" />
<TextView
android:id="#+id/current_pw_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/line"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="30dp"
android:text="#string/current_pw_string"
android:textColor="#color/black"
android:textSize="13sp" />
<EditText
android:id="#+id/current_pw_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/current_pw_label"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="15dp"
android:backgroundTint="#color/email_password_edittext_line_color_selector"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:textColor="#color/black"
android:textSize="17sp" />
<TextView
android:id="#+id/new_pw_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/current_pw_input"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="30dp"
android:text="#string/new_pw_string"
android:textColor="#color/black"
android:textSize="13sp" />
<EditText
android:id="#+id/new_pw_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/new_pw_label"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="15dp"
android:backgroundTint="#color/email_password_edittext_line_color_selector"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:textColor="#color/black"
android:textSize="17sp" />
<TextView
android:id="#+id/validate_pw_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/new_pw_input"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="30dp"
android:text="#string/validate_new_pw_string"
android:textColor="#color/black"
android:textSize="13sp" />
<EditText
android:id="#+id/validate_pw_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/validate_pw_label"
android:layout_marginBottom="30dp"
android:layout_marginEnd="35dp"
android:layout_marginStart="35dp"
android:layout_marginTop="15dp"
android:backgroundTint="#color/email_password_edittext_line_color_selector"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:textColor="#color/black"
android:textSize="17sp" />
<!--for responsive layout Button should be out side of scroll -->
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/submit_btn"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_alignParentBottom="true"
android:background="#drawable/update_profile_btn_selector"
android:text="#string/update_change"
android:textColor="#color/white"
android:textSize="20sp" />
</RelativeLayout>
I am facing this strange issue with my layout that too only in htc devices.
This is how the original layout looks
This is how it looks in device
This is the xml code for the following
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/topRl"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#color/white">
<Button
android:id="#+id/backBtn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:background="#drawable/back_arrow" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:text="#string/register_heading"
android:textColor="#color/black"
android:textSize="#dimen/text_size_for_heading" />
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="3px"
android:background="#drawable/shadow_down"
/>
<ScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/mainLinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<Button
android:id="#+id/registerWithFacebookBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20px"
android:background="#drawable/blue_dark_btn_selector"
android:text="#string/register_with_facebook"
android:textColor="#drawable/white_color_selector"
android:textSize="#dimen/text_18sp" />
<LinearLayout
android:id="#+id/etLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:orientation="vertical"
>
<EditText
android:id="#+id/firstNameEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/first_name"
android:imeOptions="actionNext"
android:inputType="textPersonName|textNoSuggestions|textCapSentences"
android:maxLines="1"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/lastNameEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/last_name"
android:inputType="textPersonName|textNoSuggestions|textCapSentences"
android:maxLines="1"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<!--<RelativeLayout
android:id="#+id/rlCountryCode"
android:layout_width="150px"
android:layout_height="#dimen/edit_text_height"
android:layout_alignParentLeft="true">
<TextView
android:id="#+id/tvCountryCode"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5px"
android:background="#drawable/edit_text_bg"
android:gravity="center"
android:paddingLeft="20px"
android:paddingRight="20px"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textSize="#dimen/text_size_edit_text" />
<Button
android:id="#+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="14px"
android:layout_height="11px"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10px"
android:background="#drawable/down_arrow_btn_selector"
android:clickable="false"
android:duplicateParentState="true" />
</RelativeLayout>-->
<EditText
android:id="#+id/phoneNoEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="5px"
android:layout_toRightOf="#+id/rlCountryCode"
android:digits="0123456789"
android:hint="#string/phone_number"
android:inputType="phone|textNoSuggestions"
android:maxLength="10"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/emailIdEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/email_id"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/passwordEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/password"
android:inputType="textPassword"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/confirmPasswordEt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/confirm_password"
android:inputType="textPassword"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<EditText
android:id="#+id/aboutUsET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:hint="#string/hear_about_us"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textColor="#color/edit_text_text_color"
android:textColorHint="#color/edit_text_hint_color"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_size_edit_text" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="3dp"
android:layout_marginLeft="20px"
android:layout_marginRight="20px"
android:paddingTop="5dp">
<CheckBox
android:id="#+id/agree_chk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="#drawable/check_box_selector"
android:padding="5dp"
android:text="#string/agree_text"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/terms_of_use_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/terms_of_use"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/and_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="and"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold"/>
</LinearLayout>
<TextView
android:id="#+id/privacy_policy_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="40dp"
android:text="#string/privacy_policy"
android:textColor="#color/black"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="#+id/signUpBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/btn_corner_margin"
android:layout_marginTop="#dimen/btn_corner_margin"
android:background="#drawable/blue_dark_btn_selector"
android:text="#string/register"
android:textColor="#drawable/btn_text_color_selector"
android:textSize="#dimen/button_text_size"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
I tried creating different layout according to different screen sizes but it still looks the same with no effect at all. I also have proper drawables in different folders.
I have simple RelativeLayout with multiple elements. But the display is not as expected with some elements jumbled and on top of each other. It seems very strange to me and I am unable to figure out why it is so. Please see the screenshot attached.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp" >
<Button
android:id="#+id/btnClose"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:background="#21759b"
android:textColor="#FFFFFF"
android:text="Close" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add a missing Business"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:textColor="#21759b"
android:layout_below="#+id/btnClose"
android:layout_centerHorizontal="true"/>
<Spinner
android:id="#+id/spinnerContactType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:minWidth="250dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_below="#+id/title"
android:entries="#array/contactType" />
<android.support.design.widget.TextInputLayout
android:id="#+id/name_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/spinnerContactType" >
<EditText
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/speciality_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/name_layout" >
<EditText
android:id="#+id/speciality"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business speciality" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/address_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/speciality_layout" >
<EditText
android:id="#+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Address" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/name_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/address_layout" >
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Phone" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/email_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/phone_layout" >
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Email" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/timings_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/email_layout" >
<EditText
android:id="#+id/timings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Timings" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="100dp"
android:layout_below="#+id/timings_layout"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:background="#21759b"
android:textColor="#FFFFFF"
android:layout_centerHorizontal="true"
android:text="Submit.." />
</RelativeLayout>
</ScrollView>
You can always use LinearLayout in these situations and its easier to manage but
if you don't want to change, this is your fixed layout :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp" >
<Button
android:id="#+id/btnClose"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:background="#21759b"
android:textColor="#FFFFFF"
android:text="Close" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add a missing Business"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:textColor="#21759b"
android:layout_below="#id/btnClose"
android:layout_centerHorizontal="true"/>
<Spinner
android:id="#+id/spinnerContactType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:minWidth="250dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_below="#id/title"
android:entries="#array/contactType" />
<android.support.design.widget.TextInputLayout
android:id="#+id/name_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/spinnerContactType" >
<EditText
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/speciality_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/name_layout" >
<EditText
android:id="#+id/speciality"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business speciality" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/address_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/speciality_layout" >
<EditText
android:id="#+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Address" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/phone_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/address_layout" >
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Phone" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/email_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/phone_layout" >
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Email" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/timings_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/email_layout" >
<EditText
android:id="#+id/timings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Timings" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="100dp"
android:layout_below="#+id/timings_layout"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:background="#21759b"
android:textColor="#FFFFFF"
android:layout_centerHorizontal="true"
android:text="Submit.." />
</RelativeLayout>
first problem with your code was in your case everywhere you used android:layout_below you should use #id/view_id because you had defined that view before and not #+id/view_id
the second problem was you added android:layout_below="#id/phone_layout" and you didn't define phone_layout you had only a view id of name_phone
hope this helps.
I quick review shows that the TextInputLayout with id email_layout uses a layout_below with an unused id of phone_layout.
Perhaps you meant it to reference name_phone. Doing so (or alternately changing the name_phone id) appears to remove the overlapping elements.
Also, I believe the use of #+id/... is only used for the first reference so subsequent references are typically #id/...
in your relative layout use
android:layout_height="wrap_content"
and set proper value for android:layout_marginTopOne more thing you are usin android:layout_below="#+id/phone_layout"but you haven't defined phone_layout
Make it easier for yourself and use LinearLayout instead on a vertical orientation.
I guess you want your email_layout to be below phone_layout, but look - you don't have the layout with id phone_layout - instead of it you have name_phone id. So all you need is to change name_phone id to phone_layout. Good luck :)
I just put a linear layout inside a scrollview dont know why its not working.
When the keyboard is open the scrollbar is not showing at all. When i move one text box to another there is a submit button which is not show when i run on small size devices.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/layoutPopUp"
android:layout_width="match_parent"
android:layout_height="79dp"
android:background="#F57F20"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:visibility="visible">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout
android:id="#+id/backlayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:orientation="horizontal">
<ImageButton
android:id="#+id/btnBackbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#color/transparent"
android:gravity="center"
android:src="#drawable/back"
android:visibility="visible" />
<TextView
android:id="#+id/textBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:gravity="center"
android:text="Back"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:id="#+id/textTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.6"
android:gravity="center"
android:text="Contact Us"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20sp"
android:textStyle="bold" />
<ImageButton
android:id="#+id/imagePopUp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.2"
android:background="#color/transparent"
android:gravity="center"
android:src="#drawable/menu"
android:visibility="visible" />
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black">
<requestFocus />
</EditText>
<EditText
android:id="#+id/editPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="Phone No."
android:inputType="phone"
android:maxLength="12"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<EditText
android:id="#+id/editEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<EditText
android:id="#+id/editComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:gravity="start"
android:hint="Comments"
android:inputType="textMultiLine"
android:lines="3"
android:maxLength="500"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#2b2b2b"
android:textColorHint="#2b2b2b"
android:textCursorDrawable="#color/black" />
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_shape"
android:text="SUBMIT"
android:textColor="#color/white" />
</LinearLayout>
</ScrollView>
</LinearLayout>
try to put scrollview inside another linear layout and try
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/parentLin"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="//define in dp"
android:scrollbars="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:textColorHint="#2b2b2b"
android:textColor="#2b2b2b"
android:ems="10"
android:hint="Name"
android:inputType="textPersonName"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium">
<requestFocus />
</EditText>
<EditText
android:id="#+id/editPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:textColor="#2b2b2b"
android:hint="Phone No."
android:inputType="phone"
android:textColorHint="#2b2b2b"
android:maxLength="12"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:textColor="#2b2b2b"
android:ems="10"
android:textColorHint="#2b2b2b"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/editboxshap"
android:ems="10"
android:gravity="start"
android:textColor="#2b2b2b"
android:hint="Comments"
android:textColorHint="#2b2b2b"
android:inputType="textMultiLine"
android:lines="3"
android:maxLength="500"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center">
<Button
android:id="#+id/btnSubmit"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_shape"
android:text="SUBMIT"
android:textColor="#color/white" />
</RelativeLayout>
</RelativeLayout>
and You have to specify the following line of code in the manifest file with your activity
android:windowSoftInputMode="adjustResize"
try This.. on your activity / fragment
getActivity().getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE |
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
I have a button inside relative layout that I want to center along with input edit text. I added android:gravity="center" to relative layout, every was centered correctly other than the button, I even tried to add android:layout_centerInParent="true" to the button but it didn't work. What could be the issue?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_gravity="bottom">
<ImageView
android:id="#+id/imageView"
android:src="#drawable/logo"
android:layout_weight=".3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"/>
<RelativeLayout
android:layout_weight=".1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<EditText
android:id="#+id/et_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:inputType="textEmailAddress"
android:ems="10"
android:hint="Email"/>
<EditText
android:id="#+id/et_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_email"
android:inputType="textPassword"
android:hint="Password"
android:ems="10"
android:layout_marginBottom="20dp"
android:imeOptions="actionDone"/>
<Button
android:id="#+id/b_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_password"
android:text="Login"/>
</RelativeLayout>
<View
android:layout_weight=".1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
Button is not centered:
android:gravity="center" is a property of LinearLayout so its direct child (the RelativeLayout) inside of it. You still need to center the children inside the RelativeLayout. To center the Button inside of its parent RelativeLayout use android:layout_centerHorizontal="true"
<Button
android:id="#+id/b_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_password"
android:text="Login"
android:layout_centerHorizontal="true"/> // here
Docs
Update
Center each View inside of the RelativeLayout
<RelativeLayout
android:layout_weight=".1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<EditText
android:id="#+id/et_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:inputType="textEmailAddress"
android:ems="10"
android:hint="Email"
android:layout_centerHorizontal="true"/>
<EditText
android:id="#+id/et_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_email"
android:inputType="textPassword"
android:hint="Password"
android:ems="10"
android:layout_marginBottom="20dp"
android:imeOptions="actionDone"
android:layout_centerHorizontal="true"/>
<Button
android:id="#+id/b_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_password"
android:text="Login"
android:layout_centerHorizontal="true"/>
Try this code:
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_gravity="bottom">
<ImageView
android:id="#+id/imageView"
android:src="#drawable/logo"
android:layout_weight=".3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"/>
<RelativeLayout
android:layout_weight=".1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<EditText
android:id="#+id/et_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:inputType="textEmailAddress"
android:ems="10"
android:hint="Email"/>
<EditText
android:id="#+id/et_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_email"
android:inputType="textPassword"
android:hint="Password"
android:ems="10"
android:layout_marginBottom="20dp"
android:imeOptions="actionDone"/>
<Button
android:id="#+id/b_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_password"
android:layout_gravity="center"
android:text="Login"/>
</RelativeLayout>
<View
android:layout_weight=".1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
Try this.. Use LinearLayout instead of RelativeLayout
<LinearLayout
android:layout_weight=".1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<EditText
android:id="#+id/et_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:inputType="textEmailAddress"
android:ems="10"
android:hint="Email"/>
<EditText
android:id="#+id/et_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_email"
android:inputType="textPassword"
android:hint="Password"
android:ems="10"
android:layout_marginBottom="20dp"
android:imeOptions="actionDone"/>
<Button
android:id="#+id/b_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_password"
android:text="Login" />
</LinearLayout>
OR in Your same layout just remove android:gravity="center" add android:layout_centerHorizontal="true" for each EditText and Button
<RelativeLayout
android:layout_weight=".1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:inputType="textEmailAddress"
android:layout_centerHorizontal="true"
android:ems="10"
android:hint="Email"/>
<EditText
android:id="#+id/et_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_email"
android:inputType="textPassword"
android:hint="Password"
android:layout_centerHorizontal="true"
android:ems="10"
android:layout_marginBottom="20dp"
android:imeOptions="actionDone"/>
<Button
android:id="#+id/b_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_password"
android:layout_centerHorizontal="true"
android:text="Login" />
</RelativeLayout>