Push the activity Content up while keyboard is on not working - android

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" /> <<<<<<<<<<<<<<<

Related

After Tap on EditText Android not show Keyboard only on some devices

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.

Move Layout Up when Soft Keyboard appears

I have login page with Email Id ,Password & LOGIN button. Right now when any one of the Edit Text gain focus then system keyboard hides my Login button. I want to push my layout above when keyboard appears keeping LOGIN button above of keyboard.
P.S I've tried all solution like
adjust Pan|adjust Resize, adjust Pan,adjust Resize"
in manifest as well as in Java code
But none of thing worked for me.
<ScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/newl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="145dp"
android:drawablePadding="8dp"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_clock"
android:id="#+id/clock"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Timetracker"
android:fontFamily="LucidaGrande"
android:textSize="30dp"
android:textAlignment="center"
android:layout_marginTop="15dp"
android:layout_gravity="center_horizontal"
android:id="#+id/tt"
android:layout_below="#+id/clock"
android:textColor="#FFFFFF"
android:layout_centerHorizontal="true"
/>
<LinearLayout
android:layout_below="#+id/tt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="30dp"
>
<ImageView
android:layout_marginLeft="7dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_person_black_24dp"
android:layout_centerVertical="true"
/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#FFFFFF"
android:layout_marginLeft="9dp"
android:drawablePadding="12dp"
android:textSize="15dp"
android:layout_marginRight="45dp"
android:fontFamily="Sans Serif"
android:layout_centerInParent="true"
android:textColor="#FFFFFF"
android:background="#android:color/transparent"
android:id="#+id/spinner2"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_drop_down_black_24dp"
android:layout_alignParentRight="true"
android:paddingRight="8dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
<View
android:layout_below="#+id/rel"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_height="1dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/lock"
android:drawablePadding="12dp"
android:layout_marginTop="30dp"
android:layout_below="#+id/rel"
android:layout_marginRight="7dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="7dp"
android:hint="Password"
android:background="#android:color/transparent"
android:textColorHint="#FFFFFF"
android:textSize="20dp"
android:textColor="#FFFFFF"
android:id="#+id/editText"
android:inputType="textPassword"
android:backgroundTint="#FFFFFF"
/>
<View
android:layout_below="#+id/editText"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_height="1dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_below="#+id/editText"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:background="#FFFFFF"
android:text="LOG IN"
android:id="#+id/log"
android:textColor="#D04045"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
The solution was to use android:fillViewport="true" on the ScrollView.
and with this you can also use android:windowSoftInputMode="adjustResize"
this worked for me
try this,
Add the below line in your manifest file,
android:windowSoftInputMode="adjustResize"
For example,
<activity android:name=".Game" android:windowSoftInputMode="adjustResize">
</activity>

Background image resizes every time keyboard is opened

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".

android virtual keyboard changes the position of button and place it over edittext on focus

I have created an app in which there is an edittext to take input from user and below it there is an button. When the user click or focus on the edittext to input something the button position is changed by the keyboard and it overlap the edittext. I have tried the solution provided in
this answer. But it doesn't helped me
i have used this
android:windowSoftInputMode="stateVisible|adjustNothing
please someone hep....
Edit:
This is my layout xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#ffffff"
tools:context=".MyAds"
android:id="#+id/TestAd"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
<EditText
android:id="#+id/edtLoanAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtLoanAmount"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtLoanAmount"
android:ems="10"
android:background="#drawable/rounded_edittext_states"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/edtRateOfInterest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtRateOfInerest"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtRateOfInerest"
android:ems="10"
android:background="#drawable/rounded_edittext_states"
android:inputType="numberDecimal" />
<TextView
android:id="#+id/txtRateOfInerest"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/edtLoanAmount"
android:layout_below="#+id/edtLoanAmount"
android:layout_marginTop="14dp"
android:text="Rate of Inerest"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtLoanAmount"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="16dp"
android:text="Enter Loan Amount"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtLoanTenure"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/edtRateOfInterest"
android:layout_marginTop="16dp"
android:text="Loan Tenure (In Months)"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/edtLoanTenure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtLoanTenure"
android:ems="10"
android:background="#drawable/rounded_edittext_states"
android:inputType="number" />
<TextView
android:id="#+id/txtEMI"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/btnCalculateEmi"
android:layout_marginTop="20dp"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/btnLoanAmorSchedule"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtEMI"
android:layout_marginTop="16dp"
android:background="#drawable/rounded_button_states"
android:text="Loan Amortization Schedule" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="125dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="#drawable/initqube" />
<Button
android:id="#+id/btnCalculateEmi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingTop="3dp"
android:layout_marginTop="5dp"
android:layout_below="#id/edtLoanTenure"
android:background="#drawable/rounded_button_states"
android:text="Calculate EMI" />
<com.google.android.gms.ads.AdView
android:id="#+id/MyAdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/imageView1"
android:layout_alignParentLeft="true"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxx" >
</com.google.android.gms.ads.AdView>
</RelativeLayout>
</ScrollView>
my issue has been solved...
<Button
android:id="#+id/btnCalculateEmi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingTop="3dp"
android:layout_marginTop="5dp"
android:layout_below="#id/edtLoanTenure"
android:background="#drawable/rounded_button_states"
android:text="Calculate EMI" />
After removing the
android:layout_centerVertical="true"
from the button property. Everything works like a charm...
Add android:windowSoftInputMode="adjustPan"
in the Android Manifest XML file for your Activity.

Background Image Stretched when taping text filed inside scroll view

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"

Categories

Resources