I have an activity and a fragment in my application.The activity consists of a RelativeLayout which is the holder for the fragment.I set a drawable image as background of the RelativeLayout.Upon clicking the EditText the keyboard opens which causes the background image of the relativelayout to resize.
Code:
AndroidManifest.xml:
<activity
android:name=".MainActivity"
android:windowSoftInputMode="stateVisible|adjustResize">
If I remove 'adjustResize', then I can't scroll the view.
holder_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="#dimen/img_wdth"
android:layout_height="#dimen/img_hght"
android:layout_alignParentLeft="true"
android:layout_marginLeft="15dp"
android:id="#+id/usr_name_img"
android:src="#drawable/user"
android:tint="#ffffff"
android:layout_marginTop="#dimen/img_mrgn_top"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="#dimen/txt_height"
android:id="#+id/name"
android:textColor="#ffffff"
android:layout_toRightOf="#+id/usr_name_img"
android:background="#drawable/edittext_bg"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="#dimen/lyt_mrgn_top"
android:hint="Your name"
android:textColorHint="#ffffff"
android:paddingLeft="30dp"
android:inputType="textMultiLine" />
<ImageView
android:layout_width="#dimen/img_wdth"
android:layout_height="#dimen/img_hght"
android:layout_below="#+id/name"
android:layout_marginTop="20dp"
android:layout_marginLeft="15dp"
android:id="#+id/place_img"
android:src="#drawable/location"
android:tint="#ffffff"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="#dimen/txt_height"
android:layout_below="#+id/name"
android:id="#+id/locality"
android:background="#drawable/edittext_bg"
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:hint="Locality"
android:textColorHint="#ffffff"
android:paddingLeft="30dp"
android:layout_alignLeft="#+id/name"
android:layout_alignStart="#+id/name"
android:inputType="textMultiLine" />
<ImageView
android:layout_width="#dimen/img_wdth"
android:layout_height="#dimen/img_hght"
android:id="#+id/email_img"
android:src="#drawable/email"
android:tint="#ffffff"
android:layout_below="#+id/locality"
android:layout_marginTop="20dp"
android:layout_marginLeft="15dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="#dimen/txt_height"
android:layout_below="#+id/locality"
android:id="#+id/email"
android:textColor="#ffffff"
android:background="#drawable/edittext_bg"
android:inputType="textEmailAddress"
android:layout_marginTop="10dp"
android:hint="E-Mail"
android:textColorHint="#ffffff"
android:paddingLeft="30dp"
android:layout_alignLeft="#+id/locality"
android:layout_alignStart="#+id/locality"
android:layout_alignRight="#+id/locality"
android:layout_alignEnd="#+id/locality" />
<ImageView
android:layout_width="#dimen/img_wdth"
android:layout_height="#dimen/img_hght"
android:layout_below="#+id/email"
android:src="#drawable/phone"
android:tint="#ffffff"
android:id="#+id/mobile_img"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="#dimen/txt_height"
android:layout_below="#+id/email"
android:id="#+id/phone"
android:background="#drawable/edittext_bg"
android:layout_marginTop="10dp"
android:hint="Mobile No."
android:textColor="#ffffff"
android:inputType="phone"
android:textColorHint="#ffffff"
android:paddingLeft="30dp"
android:layout_alignLeft="#+id/email"
android:layout_alignStart="#+id/email"
android:layout_alignRight="#+id/email"
android:layout_alignEnd="#+id/email" />
<ImageView
android:layout_width="#dimen/img_wdth"
android:layout_height="#dimen/img_hght"
android:layout_below="#+id/phone"
android:src="#drawable/event"
android:tint="#ffffff"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:id="#+id/imageView2" />
<Spinner
android:layout_width="match_parent"
android:layout_height="#dimen/txt_height"
android:gravity="center"
android:overlapAnchor="false"
android:background="#drawable/edittext_bg"
android:popupBackground="#BB000000"
android:layout_below="#+id/phone"
android:spinnerMode="dropdown"
android:id="#+id/eventspinner"
android:layout_marginTop="10dp"
android:layout_alignLeft="#+id/phone"
android:layout_alignStart="#+id/phone"
android:layout_alignRight="#+id/phone"
android:layout_alignEnd="#+id/phone"></Spinner>
<EditText
android:layout_width="match_parent"
android:layout_height="#dimen/txt_height"
android:id="#+id/bdgt"
android:inputType="numberDecimal"
android:hint="Your Budget"
android:textColorHint="#ffffff"
android:paddingLeft="25dp"
android:textColor="#ffffff"
android:layout_below="#+id/eventspinner"
android:background="#drawable/edittext_bg"
android:layout_marginTop="10dp"
android:layout_alignLeft="#+id/eventspinner"
android:layout_alignStart="#+id/eventspinner"
android:layout_alignRight="#+id/eventspinner"
android:layout_alignEnd="#+id/eventspinner" />
<Button
android:layout_width="match_parent"
android:layout_height="#dimen/btn_height"
android:id="#+id/book"
android:background="#drawable/btn_bg"
android:layout_centerHorizontal="true"
android:text="Book Now"
android:textColor="#ffffff"
android:layout_marginLeft="90dp"
android:layout_below="#+id/noOfPeople"
android:layout_marginTop="40dp"/>
<ImageView
android:layout_width="10dp"
android:layout_height="#dimen/drp_dwn_arrw_hght"
android:layout_below="#+id/phone"
android:layout_alignParentRight="true"
android:layout_marginRight="25dp"
android:layout_marginTop="25dp"
android:src="#drawable/downarrow"
android:tint="#ffffff"
android:id="#+id/imageView" />
<ImageView
android:layout_width="#dimen/img_wdth"
android:layout_height="#dimen/img_hght"
android:id="#+id/bdgt_img"
android:src="#drawable/budget"
android:tint="#ffffff"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp"
android:layout_below="#+id/eventspinner"/>
<EditText
android:layout_width="match_parent"
android:layout_height="#dimen/txt_height"
android:id="#+id/noOfPeople"
android:layout_marginTop="10dp"
android:background="#drawable/edittext_bg"
android:hint=" Number ofpeople"
android:paddingLeft="25dp"
android:textColorHint="#ffffff"
android:textColor="#ffffff"
android:inputType="number"
android:layout_toRightOf="#+id/group"
android:layout_below="#+id/bdgt"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>
<ImageView
android:layout_width="#dimen/img_wdth"
android:layout_height="#dimen/img_hght"
android:id="#+id/group"
android:tint="#ffffff"
android:src="#drawable/group"
android:layout_marginTop="20dp"
android:layout_below="#+id/bdgt"
android:layout_alignLeft="#+id/bdgt_img"
android:layout_alignStart="#+id/bdgt_img" />
</RelativeLayout>
</ScrollView>
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="#+id/cstm_toolbar"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="#AB47BC">
</android.support.v7.widget.Toolbar>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/bg"
android:layout_centerHorizontal="true"
android:id="#+id/frag_holder"
android:layout_below="#+id/cstm_toolbar"
></LinearLayout>
</RelativeLayout>
Use this in the Manifest file.
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
and remove background image from Xml file and set it via Java code using below way
getWindow().setBackgroundDrawableResource(R.drawable.bg);
try to this hope this can help you..
<RelativeLayout
android:layout_width="match_parent" -->#dimen/img_wdth
android:layout_height="match_parent" -->#dimen/img_hght
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="#dimen/img_wdth"
android:layout_height="#dimen/img_hght"
android:layout_alignParentLeft="true"
android:layout_marginLeft="15dp"
android:id="#+id/usr_name_img"
android:src="#drawable/user"
android:tint="#ffffff"
android:layout_marginTop="#dimen/img_mrgn_top"
/>
And also try in Manifest with "adjustPan".
Related
I tried adding android:windowSoftInputMode in AndroidManifest.xml file and
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
both of them are not working.Even tried adding some WorkAround code from stack Overflow.Nothing is changing.
In my xml i used RelativeLayout which is wrapped under ScrollView. The scrollview contains only one child i.e. RelativeLayout
Please help me to do it.I have been stuck with this issue for long time.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<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:background="#color/colorWhite"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context="ca.com.helptree.Activities.LoginActivity">
<ImageView
android:id="#+id/imglogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="62dp"
app:srcCompat="#drawable/appicon" />
<TextView
android:id="#+id/txtAppName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imglogo"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="#string/app_Uname"
android:textColor="#color/colorBlack"
android:textSize="20sp" />
<TextView
android:id="#+id/tvCCode"
android:layout_width="70dp"
android:layout_height="30dp"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtAppName"
android:layout_marginStart="25dp"
android:layout_marginTop="26dp"
android:background="#xml/rounded_corner"
android:ems="10"
android:gravity="center"
android:hint="+Code"
android:text=""
android:textAlignment="center"
android:textColor="#color/colorBlack" />
<EditText
android:id="#+id/etxtMobileNo"
android:layout_width="225dp"
android:layout_height="30dp"
android:layout_alignTop="#+id/tvCCode"
android:layout_marginStart="26dp"
android:layout_toEndOf="#+id/tvCCode"
android:background="#xml/rounded_corner"
android:ems="10"
android:gravity="center"
android:hint="Mobile No"
android:inputType="phone"
android:textColor="#color/colorBlack" />
<android.support.design.widget.TextInputLayout
android:id="#+id/txtILayout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignEnd="#+id/etxtMobileNo"
android:layout_below="#+id/tvCCode"
android:layout_marginStart="25dp"
android:layout_marginTop="13dp"
android:textAlignment="center"
app:hintEnabled="false"
app:passwordToggleEnabled="true">
<EditText
android:id="#+id/etxtPassword"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#xml/rounded_corner"
android:gravity="center"
android:hint="Password"
android:inputType="textPassword"
android:textAlignment="center"
android:textColor="#color/colorBlack" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btnSignup"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/txtILayout"
android:layout_below="#+id/txtILayout"
android:layout_marginTop="11dp"
android:background="#xml/signup_button"
android:text="#string/Signup"
android:textColor="#color/colorWhite" />
<Button
android:id="#+id/btnSignin"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/txtILayout"
android:layout_alignTop="#+id/btnSignup"
android:background="#xml/signin_button"
android:text="#string/Signin"
android:textColor="#color/colorWhite" />
</RelativeLayout></ScrollView>
On your AndroidManifest.xml file put this last line
<activity
android:name="at.next.neah.screens.service.activitys.MY_Activity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize" /> <<<<<<<<<<<<<<<
somethings strange happen when some (not all) users tap on EditText.
Keyboard not appear.
The layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:foo="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
android:focusableInTouchMode="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/estra" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background_color" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#color/trasparent"
android:gravity="center"
android:navigationIcon="#drawable/back_normal"
android:textAlignment="center"
foo:layout_collapseMode="pin">
<it.estraspa.areaclienti.utilities.ui.TextViewEstra
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:text="#string/accedi"
android:textColor="#color/white"
android:textSize="18sp"
foo:Overpass="bold" />
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="#+id/ll_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_below="#id/toolbar"
android:layout_centerVertical="true"
android:layout_marginTop="20dp"
android:orientation="vertical">
<it.estraspa.areaclienti.utilities.ui.TextViewEstra
android:id="#+id/tv_login_error"
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginBottom="#dimen/small_margin"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="50dp"
android:background="#drawable/custom_error_shape"
android:drawableLeft="#drawable/icon_error_msg"
android:drawablePadding="#dimen/normal_margin"
android:paddingStart="#dimen/normal_margin"
android:paddingTop="5dp"
android:text=""
android:textColor="#color/white"
android:textSize="#dimen/text_25px_sp13"
android:visibility="invisible"
foo:Overpass="light" />
<android.support.design.widget.TextInputLayout
android:id="#+id/til_codice_cliente"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/small_margin"
android:textColorHint="#color/white">
<it.estraspa.areaclienti.utilities.ui.EditTextEstra
android:id="#+id/et_codice_cliente"
style="#style/SingleLineText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="25dp"
android:backgroundTint="#color/white"
android:hint="#string/nome_utente"
android:inputType="text"
android:minHeight="50dp"
android:textColor="#color/white"
android:textColorHighlight="#color/white"
android:textColorHint="#color/white"
android:textSize="#dimen/text_size_37px_18dp"
foo:Overpass2="regular" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_codice_fiscale"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/white"
foo:passwordToggleEnabled="true"
foo:passwordToggleTint="#color/white">
<it.estraspa.areaclienti.utilities.ui.EditTextEstra
android:id="#+id/et_codice_fiscale"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="#dimen/small_margin"
android:backgroundTint="#color/white"
android:hint="#string/password"
android:inputType="textPassword"
android:maxLines="1"
android:minHeight="50dp"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="#dimen/text_size_37px_18dp"
foo:Overpass2="regular"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_text2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/ll_text"
android:layout_marginTop="20dp"
android:orientation="vertical">
<it.estraspa.areaclienti.utilities.ui.ButtonEstra
android:id="#+id/bt_accedi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/bt_registrati"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#drawable/custom_button_on_blu_background"
android:clickable="true"
android:minHeight="50dip"
android:minWidth="285dp"
android:text="#string/accedi"
android:textColor="#color/colorPrimaryDark"
android:textSize="#dimen/size_16sp_31_px"
foo:Overpass3="bold" />
<it.estraspa.areaclienti.utilities.ui.TextViewEstra
android:id="#+id/tvForgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:clickable="true"
android:elevation="16dp"
android:gravity="center"
android:text="#string/password_dimenticata"
android:textColor="#color/white"
android:textSize="#dimen/text_14sp_27px"
foo:Overpass="bold" />
<ImageView
android:id="#+id/tvnoaccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/ll_text2"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="60dp"
android:src="#drawable/text_no_account"
android:visibility="gone" />
<it.estraspa.areaclienti.utilities.ui.ButtonEstra
android:id="#+id/bt_registrati"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tvnoaccount"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:background="#drawable/custom_button_transparent"
android:clickable="true"
android:minHeight="50dip"
android:minWidth="285dp"
android:text="#string/registrati"
android:textColor="#color/white"
android:textSize="#dimen/size_16sp_31_px"
android:visibility="gone"
foo:Overpass3="bold" />
</LinearLayout>
</RelativeLayout>
My Manifest
<activity
android:name=".presentationlayer.activities.LoginActivity"
android:screenOrientation="portrait"
android:theme="#style/EstraStyle"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
/>
If I remove this line from manifest
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
Keyboard will work fine on all devices?
I can not reproduce the situation because I not have the specific devices.
Remove stateAlwaysHidden. It tells the OS not to show the keyboard in this activity unless shown explicitly.
i am having an issue in over-lapping layouts,i am trying to implement an login form with in the entire page , and a button at the bottom , when the user press this button a registration form slides from bottom to up , my problems are:the first the registration form push the entire screen (i want it to overflow), the second: that i have 2 buttons with a shape background that appears on the top of registration form and the login inputs remains active
my xml code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/content_login_page"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg"
tools:context="com.example.a3wd.mytest10.LoginPage"
tools:showIn="#layout/activity_login_page">
<ImageView
android:id="#+id/login2Logo"
android:layout_width="50dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:contentDescription="#string/fixawy_logoPic"
android:src="#drawable/logo2" />
<LinearLayout
android:id="#+id/loginInputs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/login2Logo"
android:layout_marginTop="30dp"
android:orientation="vertical">
<TextView
android:layout_width="140dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:text="#string/loginText"
android:textColor="#color/loginText"
android:textSize="24sp"
android:textStyle="bold" />
<EditText
android:id="#+id/userEmail"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginEnd="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/myspinner"
android:hint="#string/nameHint"
android:inputType="textEmailAddress"
android:padding="10dp" />
<EditText
android:id="#+id/userPassword"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginEnd="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="8dp"
android:background="#drawable/myspinner"
android:hint="#string/passwordHint"
android:inputType="textPassword"
android:padding="10dp"
android:textAlignment="textEnd" />
</LinearLayout>
<Button
android:id="#+id/loginBtn"
android:layout_width="96dp"
android:layout_height="56dp"
android:layout_below="#id/loginInputs"
android:layout_marginLeft="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/shape_round_corner"
android:text="#string/enterBtnTxt"
/>
<TextView
android:id="#+id/passwordText"
android:layout_width="150dp"
android:layout_height="30dp"
android:layout_alignBaseline="#id/loginBtn"
android:layout_alignParentRight="true"
android:layout_below="#id/loginInputs"
android:layout_marginRight="50dp"
android:text="#string/forgetPassword"
android:textColor="#color/loginText"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/facebookTxt"
android:layout_width="200dp"
android:layout_height="30dp"
android:layout_below="#id/loginBtn"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#string/facebookTxt"
android:textSize="18sp" />
<Button
android:id="#+id/facebookBtn"
android:layout_width="88dp"
android:layout_height="32dp"
android:layout_below="#id/facebookTxt"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#drawable/facebookbtn"
android:text="#string/facebook_btn"
android:textColor="#ffffff" />
<TextView
android:id="#+id/newUserTxt"
android:layout_width="140dp"
android:layout_height="20dp"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:text="#string/newUserTxt"
android:textSize="18sp"
android:layout_marginBottom="5dp"
android:layout_alignParentRight="true"
android:layout_above="#+id/registrationBtn"
/>
<Button
android:id="#id/registrationBtn"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#drawable/register_btn_shape"
android:gravity="right"
android:onClick="registerFragment"
android:layout_alignParentBottom="true"
android:paddingEnd="40dp"
android:paddingRight="30dp"
android:paddingTop="10dp"
android:text="#string/registerTxt"
android:textColor="#874f13"
android:textSize="24sp"/>
<LinearLayout
android:id="#+id/registerForm"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/newUserTxt"
android:background="#drawable/register_back"
android:orientation="vertical"
android:visibility="invisible"
>
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="right"
android:paddingEnd="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:text="#string/registerTxt"
android:textColor="#874f13"
android:textSize="24sp"
/>
</LinearLayout>
</RelativeLayout>
and the java code for animation
Animation bottomUp = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.bottom_up);
registrationForm.startAnimation(bottomUp);
registrationForm.setVisibility(View.VISIBLE);
this is the original view
and this is an image of the problem
I have a Coordinator layout in activity xml and an include layout that have a content layout xml. Like this:
<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"
android:id="#+id/main">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="#layout/content_sign_in" />
</android.support.v4.widget.NestedScrollView>
When i put my content layout inside a nestedscrollview my content layout double your heigth. Anyone can help me?
My Content layout xml:
<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:id="#+id/content_sign_in"
android:layout_width="match_parent"
android:background="#drawable/sign_up_bg"
android:layout_height="match_parent"
tools:showIn="#layout/activity_sign_in">
<ImageButton
android:id="#+id/arrow_back"
android:layout_marginTop="15dp"
android:layout_marginLeft="10dp"
android:scaleType="centerInside"
android:padding="5dp"
android:src="#drawable/ic_back_white"
android:background="#android:color/transparent"
android:layout_width="40dp"
android:layout_height="40dp" />
<ImageView
android:scaleType="centerInside"
android:layout_below="#+id/arrow_back"
android:id="#+id/logo"
android:layout_marginTop="6dp"
android:layout_centerHorizontal="true"
android:layout_width="78dp"
android:layout_height="45dp" />
<android.support.design.widget.TextInputLayout
android:textColorHint="#color/color_80ffffff"
android:id="#+id/input_layout_email"
android:layout_marginLeft="46dp"
android:hint=" "
android:layout_marginRight="46dp"
android:layout_marginTop="74dp"
android:layout_below="#+id/logo"
app:errorTextAppearance="#style/error_appearance"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/work_email"
android:gravity="center"
android:theme="#style/EditTextLogin"
android:textColorHint="#color/color_80ffffff"
android:hint="#string/hint_work_email"
android:textColor="#android:color/white"
android:textSize="14sp"
android:inputType="textEmailAddress"
android:imeOptions="actionNext"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:textColorHint="#color/color_80ffffff"
android:id="#+id/input_layout_password"
android:layout_marginLeft="46dp"
android:hint=" "
android:theme="#style/EditTextLogin"
android:layout_marginRight="46dp"
android:layout_below="#+id/input_layout_email"
app:errorTextAppearance="#style/error_appearance"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/password"
android:gravity="center"
android:textColorHint="#color/color_80ffffff"
android:hint="#string/hint_password"
android:textColor="#android:color/white"
android:textSize="14sp"
android:inputType="textPassword"
android:imeOptions="actionDone"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<Button
android:layout_below="#+id/input_layout_password"
android:id="#+id/btn_sign_in"
android:textColor="#android:color/white"
android:text="#string/btn_login"
android:layout_marginTop="26dp"
android:background="#color/colorAccent"
android:layout_marginRight="60dp"
android:layout_marginLeft="60dp"
android:layout_width="match_parent"
android:layout_height="40dp" />
<RelativeLayout
android:layout_marginTop="17dp"
android:layout_below="#+id/btn_sign_in"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/label_sign_up"
android:textSize="14sp"
android:text="#string/lbl_sign_up"
android:textColor="#color/color_80ffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_toRightOf="#+id/label_sign_up"
android:textStyle="bold"
android:layout_marginLeft="5dp"
android:id="#+id/btn_sign_up"
android:textSize="14sp"
android:text="#string/txt_sign_up"
android:textColor="#android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<TextView
android:id="#+id/forgot_password"
android:textColor="#color/color_80ffffff"
android:textSize="14sp"
android:gravity="center"
android:text="#string/text_forgot_password"
android:layout_marginBottom="20dp"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:visibility="gone"
android:id="#+id/layout_resend"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="86dp">
<ImageView
android:scaleType="fitXY"
android:src="#drawable/pink_bar"
android:layout_width="match_parent"
android:layout_height="86dp" />
<Button
android:id="#+id/btn_resend"
android:layout_marginRight="10dp"
android:layout_alignParentRight="true"
android:layout_marginTop="26dp"
android:textSize="14sp"
android:text="#string/txt_resend"
android:textColor="#color/color_505065"
android:background="#android:color/transparent"
android:layout_width="wrap_content"
android:layout_height="40dp" />
<ImageView
android:id="#+id/ic_email"
android:layout_marginLeft="16dp"
android:layout_marginTop="26dp"
android:src="#drawable/ic_email_confirmation_white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_marginLeft="15dp"
android:layout_toRightOf="#+id/ic_email"
android:layout_toLeftOf="#+id/btn_resend"
android:layout_marginTop="26dp"
android:textSize="14sp"
android:text="#string/text_resend_email"
android:textColor="#android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<RelativeLayout
android:visibility="gone"
android:id="#+id/load"
android:background="#aa000000"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="50dp"
android:layout_height="50dp" />
</RelativeLayout>
i don't know why this happen
I don't see anything wrong with your layout hierarchy. Things might be a little weird because you are using an image as a background, and no fixed height and width. I don't know if this is a XML background or a image file, but if it is the latter, I'd recommend using an image view inside the relative layout with a fixed size and a scale type defined.
I created one registration page using relative layout and applied background image to main layout. Here I used scroll view for scrolling my contents.
Problem: when I selected my textfield, background image of main relative layout stretched.
Here is my xml content:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:androidcustomfont="http://schemas.android.com/apk/res/com.cpt.realtor.activity"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="615dp" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="680dp" >
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="25dp"
android:src="#drawable/realtor_land_text" />
<EditText
android:id="#+id/editFirstName"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/firstname"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editLastName"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editFirstName"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/lastname"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editCompany"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editLastName"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/company"
android:inputType="text" />
<EditText
android:id="#+id/editMobile"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editCompany"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/mobile"
android:imeOptions="actionDone"
android:inputType="phone"
android:maxLength="10" />
<EditText
android:id="#+id/editEmail"
style="#style/activity_realtor_details_of_registration_tabletversion_for_textboxes"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editMobile"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:hint="#string/email"
android:inputType="textEmailAddress" />
<Spinner
android:id="#+id/spinnerForStates"
android:layout_width="440dp"
android:layout_height="wrap_content"
android:layout_below="#+id/editEmail"
android:layout_marginLeft="40dp"
android:layout_marginTop="10dp" />
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/spinnerForStates"
android:layout_marginLeft="50dp"
android:layout_marginTop="15dp"
android:button="#drawable/checkbox_selector"
android:text="#string/receivealert"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold" />
<com.cpt.realtor.utility.CustomFontButton
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/checkBox"
android:layout_marginLeft="180dp"
android:layout_marginTop="10dp"
android:background="#drawable/share_btn_selector"
android:text="#string/submit"
android:textColor="#android:color/white"
android:textSize="20sp"
android:textStyle="bold"
androidcustomfont:customFontView="clarendon_regular.ttf" />
<TextView
android:id="#+id/textSkip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/submit"
android:layout_marginLeft="205dp"
android:layout_marginTop="8dp"
android:textSize="15sp"
android:text="#string/skip_this_step"
android:textColor="#color/white" />
<View
android:id="#+id/splitter"
android:layout_width="93dp"
android:layout_height="1dip"
android:layout_below="#+id/textSkip"
android:layout_marginLeft="210dp"
android:layout_marginTop="0dp"
android:background="#color/white" />
<View
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/textSkip"
android:background="#drawable/footer" />
</RelativeLayout>
</ScrollView>
without selecting TextField:
After selecting TextField:
In my second image, the background image stretched. How can I solve this?
In your manifest write this in activity tag
android:windowSoftInputMode="stateVisible|adjustPan"