I have one fragment called FeedBackFragment And its a Page of ViewPager and it has scrollview. But the scroll is not working.
I have 2 xml files:
parent.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:gravity="center"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<androidx.viewpager.widget.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
I have scrollview inside *feedback.xml* and it's **not** scrolling.
*feedback.xml*
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.promediadesigns.tecosnation.CustomScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<EditText
android:id="#+id/username"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:background="#drawable/round_et"
android:gravity="center"
android:hint="Enter Full Name..."
android:inputType="textPersonName"
android:textColor="#fff"
android:textColorHint="#fff"
android:textSize="12sp" />
<EditText
android:id="#+id/email"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:background="#drawable/round_et"
android:gravity="center"
android:hint="Enter Email..."
android:inputType="textEmailAddress"
android:textColor="#fff"
android:textColorHint="#fff"
android:textSize="12sp" />
<EditText
android:id="#+id/msg"
android:layout_width="200dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:background="#drawable/greyround_et"
android:hint="Type your message here..."
android:inputType="textMultiLine"
android:textColor="#color/colorPrimary"
android:textColorHint="#color/colorPrimary"
android:textSize="15sp" />
<Button
android:id="#+id/send"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:background="#drawable/send_icon" />
</LinearLayout>
</com.promediadesigns.tecosnation.CustomScrollView>
</LinearLayout>
Can someone help me out about the scrolling?
Change your feedbak.xml to
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<EditText
android:id="#+id/username"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:gravity="center"
android:hint="Enter Full Name..."
android:inputType="textPersonName"
android:textColor="#fff"
android:textColorHint="#fff"
android:textSize="12sp" />
<EditText
android:id="#+id/email"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:gravity="center"
android:hint="Enter Email..."
android:inputType="textEmailAddress"
android:textColor="#fff"
android:textColorHint="#fff"
android:textSize="12sp" />
<EditText
android:id="#+id/msg"
android:layout_width="200dp"
android:minHeight="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:hint="Type your message here..."
android:inputType="textMultiLine"
android:textColor="#color/colorPrimary"
android:textColorHint="#color/colorPrimary"
android:textSize="15sp" />
<Button
android:id="#+id/send"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_gravity="center"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
based on the comments it seem the problem is not actually with the scroll but rather with the softkeyboard covering the editfield, as the content of the scrollview is not actually bigger than the scrollview itself, so there is nothing to scroll.
you need to set
android:windowSoftInputMode="adjustResize"
or
android:windowSoftInputMode="adjustPan"
on your activity to get expected behaviour.
"adjustResize" The activity's main window is always resized to make
room for the soft keyboard on screen.
"adjustPan" The activity's main window is not resized to make room for
the soft keyboard. Rather, the contents of the window are
automatically panned so that the current focus is never obscured by
the keyboard and users can always see what they are typing. This is
generally less desirable than resizing, because the user may need to
close the soft keyboard to get at and interact with obscured parts of
the window.
Related
I have a login activity which has android:windowSoftInputMode="adjustResize" set to fit login fields when keyboard appears. I want an image that is above the fields to get smaller so it wouldn't overlap with the login fields.
Layout:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_above="#id/et_email"
android:scaleType="fitXY"
android:src="#drawable/ic_foreground" />
<EditText
android:id="#+id/et_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/et_password"/>
<EditText
android:id="#+id/et_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/et_password" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_remind_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/btn_login"
android:layout_centerHorizontal="true" />
</RelativeLayout>
How can I achieve that?
I'm trying to test my app on Mobiwire MobiPrint with Android version 4.2.2
I put this statement in the Activity tag in the manifest file to resize the screen when the soft keyboard is visible
android:windowSoftInputMode="adjustResize|stateVisible|stateAlwaysHidden"
this is my XML file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:focusable="true"
android:focusableInTouchMode="true"
android:fitsSystemWindows="true"
android:gravity="center_vertical|center"
android:layoutDirection="rtl"
android:orientation="vertical"
tools:context="com.egpay.merchant.activities.LoginActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal|center"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="30dp"
android:paddingRight="30dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="25dp"
app:srcCompat="#drawable/egpay_logo" />
<android.support.design.widget.TextInputLayout
android:id="#+id/id_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/EditTextHint">
<EditText
android:id="#+id/input_id"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="end"
android:layout_marginBottom="10dp"
android:drawableEnd="#drawable/ic_user"
android:drawablePadding="8dp"
android:hint="#string/merchantCode"
android:inputType="number"
android:textAlignment="viewEnd"
tools:ignore="RtlCompat" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/password_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/EditTextHint">
<EditText
android:id="#+id/input_password"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="end"
android:drawableEnd="#drawable/ic_password"
android:drawablePadding="8dp"
android:hint="#string/password"
android:inputType="textPassword"
android:textAlignment="viewEnd"
tools:ignore="RtlCompat" />
</android.support.design.widget.TextInputLayout>
<CheckBox
android:id="#+id/chk_save_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:buttonTint="#color/colorPrimary"
android:checked="false"
android:gravity="left|center"
android:layoutDirection="rtl"
android:text="#string/savePassword"
android:textColor="#android:color/darker_gray"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="20dip"
android:orientation="horizontal"
android:weightSum="10">
<TextView
android:id="#+id/btn_forget"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_weight="6"
android:gravity="center_vertical"
android:text="#string/forgetPassword"
android:textAlignment="center"
android:textColor="#android:color/darker_gray"
android:textSize="16sp" />
<Button
android:id="#+id/btn_login"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
android:layout_weight="4"
android:background="#drawable/bg_colorful_btn_main"
android:text="#string/login"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="20sp" />
</LinearLayout>
<!-- Link to Login Screen -->
<Button
android:id="#+id/btn_update"
android:layout_width="300dp"
android:layout_height="50dp"
android:text="Update Now" />
</LinearLayout>
</RelativeLayout>
and here's screenshot of the result:
as you can see when the keyboard is visible the screen resize itself but the keyboard still covering some parts.
what can I do to solve this issue???
note that I tested the app on another device running Android version 5.1.1 and it's working fine
Hi can you try like this
android:windowSoftInputMode="adjustPan|adjustResize"
instead of
android:windowSoftInputMode="adjustResize|stateVisible|stateAlwaysHidden"
I am trying to make the WHOLE of the blue button (As seen on the picture) on the top of the view. However, it is only showing the button half. I have sussed out it's something to do with the elevation, however I'm not sure what as I have tried the possibilities I can think of.
My XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical"
android:baselineAligned="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="#+id/background"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#color/colorPrimary" />
<View
android:id="#+id/contentView"
android:layout_width="341dp"
android:layout_height="340dp"
android:layout_marginLeft="35dp"
android:layout_marginRight="35dp"
android:layout_marginTop="250dp"
android:background="#drawable/login_container"
android:elevation="8dp" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/contentView"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:elevation="8dp"
android:text="LOGIN"
android:textColor="#color/black"
android:textSize="24sp" />
<EditText
android:id="#+id/emailAddress"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:layout_below="#+id/background"
android:layout_centerHorizontal="true"
android:layout_marginTop="41dp"
android:elevation="8dp"
android:ems="10"
android:hint="Email address"
android:inputType="textEmailAddress"
android:textColor="#color/colorPrimary" />
<EditText
android:id="#+id/password"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:layout_below="#+id/emailAddress"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:elevation="8dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#color/colorPrimary" />
<Button
android:id="#+id/loginButton"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="45dp"
android:background="#drawable/login_button"
android:elevation="8dp"
android:text="LOGIN"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
take button out of relative layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical"
android:baselineAligned="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="#+id/background"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#color/colorPrimary" />
<View
android:id="#+id/contentView"
android:layout_width="341dp"
android:layout_height="340dp"
android:layout_marginLeft="35dp"
android:layout_marginRight="35dp"
android:layout_marginTop="250dp"
android:background="#drawable/login_container"
android:elevation="8dp" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/contentView"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:elevation="8dp"
android:text="LOGIN"
android:textColor="#color/black"
android:textSize="24sp" />
<EditText
android:id="#+id/emailAddress"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:layout_below="#+id/background"
android:layout_centerHorizontal="true"
android:layout_marginTop="41dp"
android:elevation="8dp"
android:ems="10"
android:hint="Email address"
android:inputType="textEmailAddress"
android:textColor="#color/colorPrimary" />
<EditText
android:id="#+id/password"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:layout_below="#+id/emailAddress"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:elevation="8dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#color/colorPrimary" />
</RelativeLayout>
<Button <----- change
android:id="#+id/loginButton"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="45dp"
android:background="#drawable/login_button"
android:elevation="8dp"
android:text="LOGIN"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
problem is not button elevations is your View hiding button
<View
android:id="#+id/contentView"
android:layout_width="341dp"
android:layout_height="340dp"
android:layout_marginLeft="35dp"
android:layout_marginRight="35dp"
android:layout_marginTop="250dp"
android:background="#drawable/login_container"
android:elevation="8dp" />
this part is hiding your button you can check it in xml
I would suggest using Scrol view as well because this UI wont work on small screen devices as many heights are hard coded
My apologies to be blunt, but your layout is not well designed.
You have linearLayout with nested RelativeLayout and the parent is now not serving a purpose.
Use the root that you intend to use. If it is relative layout, then use that. If you plan to stack more content below or above the relative layout then it makes sense, but your sample it doesn't serve a purpose.
Now as to your problem. You are using a relative layout and just stacking views on views on views. First, your parent should have the container background, you should not have a view nested in the parent RelativeLayout that has the background intended to be the parent's background.
So I would move your container background to the RelativeLayout and remove the view altogether as your hard coded height width on that could be playing a role as well.
So before we hunt down any goofy behaviors, let's get the design done properly first than we can see what we are looking for if it is still acting up.
Try something like this instead:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical"
android:baselineAligned="false">
<View
android:id="#+id/background"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="#color/colorPrimary" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="35dp"
android:layout_marginRight="35dp"
android:layout_marginTop="250dp"
android:orientation="vertical"
android:background="#drawable/login_container">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:elevation="8dp"
android:text="LOGIN"
android:textColor="#color/black"
android:textSize="24sp" />
<EditText
android:id="#+id/emailAddress"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:elevation="8dp"
android:ems="10"
android:hint="Email address"
android:inputType="textEmailAddress"
android:textColor="#color/colorPrimary" />
<EditText
android:id="#+id/password"
android:layout_width="270dp"
android:layout_height="wrap_content"
android:elevation="8dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#color/colorPrimary" />
<Button
android:id="#+id/loginButton"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="45dp"
android:background="#drawable/login_button"
android:elevation="8dp"
android:text="LOGIN"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
I can't test it as i don't have your code, and you will have to adjust the margins. Also, change your preview to the 3.7 so you can see that your design may need some adjusting for small devices. Lastly, you could always use a cardview for this if desired.
So I've been designing in XML in Android Studio a standard log in page - with an image covering about half of the screen, and then the edit text fields occupying the bottom half, asking for the log in details. My problem is that when I tap on the edit text fields on smaller mobile displays, it will only snap to and show the field I have selected, when I think it's far better if it were to automatically snap to show all fields and the 'Next' button at once.
An overview of the page
When I click on 'UserID' field
What I WANT to see when I click on 'UserID' field
How do I achieve this result?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context="com.example.android.brunelplanner.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="250sp"
android:background="#color/colorPrimary"
android:orientation="vertical"></LinearLayout>
<RelativeLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/logo"
android:orientation="vertical">
<LinearLayout
android:id="#+id/login_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.87"
android:gravity="center"
android:text="eVision Log in"
android:textColor="#000000"
android:textSize="20sp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_userID"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_password"
android:imeActionId="#+id/login"
android:imeActionLabel="#string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/login_fields">
<Button
android:id="#+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/action_sign_in"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Cant comment so I have to write here. If you XML in question is current, you have to align parent bottom the whole layout that you want to move up. The bottom alignment must have the whole login form not just button. Also you have linear layout on top which has fixed height, that could be a problem too.
EDIT: Ok, try this, it works on my end. BUT I simplified the XML for testing so dont copy it, just try to edit your xml.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/email_login_form"
android:layout_alignParentTop="true"
android:background="#color/colorPrimary"
android:orientation="vertical">
</LinearLayout>
<RelativeLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true">
<LinearLayout
android:id="#+id/login_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.87"
android:gravity="center"
android:text="eVision Log in"
android:textColor="#000000"
android:textSize="20sp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/email_login_form"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="sign in"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
In a screen, I have a edit text on top (large contains space for 4-5 line), image view below that and submit button at bottom. on Keyboard up it should not hide my submit button.
when keyboard appears i am able to resize the window using android:windowSoftInputMode="adjustResize" which allow me not to hide the submit button but it resize my image also which i don't want.
Only submit button should move up when keyboard is visible without resizing image.
I tried frame layout also but it didn't may be i tried wrong way. Any help will be appriciated.
Apply this and let me know is it still happening or not .
activity_mian.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:background="#drawable/xxx.jpg"
android:orientation="vertical"
tools:context=".LoginActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_marginTop="20dp"
android:src="#drawable/logo_app" />
<EditText
android:id="#+id/edtEmail"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/login_textbox"
android:ems="10"
android:hint="Email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:singleLine="true"
android:textColor="#ffffff"
android:textCursorDrawable="#null" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/edtPassword"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/login_textbox"
android:ems="10"
android:hint="Password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:singleLine="true"
android:textColor="#ffffff"
android:textCursorDrawable="#null" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/edtPassword"
android:layout_marginTop="2dp" />
</RelativeLayout>
<CheckBox
android:id="#+id/checkBox_remember"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:button="#drawable/checkbox_selector"
android:checked="true"
android:focusable="false"
android:focusableInTouchMode="true"
android:text=" Remember Me"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<Button
android:id="#+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="top|center_vertical|center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#drawable/btn_login" />
</LinearLayout>
</LinearLayout>
</ScrollView>
set your Button, EditText etc.. inside one linear layout followed by one parent ScrollView .
one another thing is that set android:windowSoftInputMode="stateAlwaysHidden"
inside your java file where your xml file is bind .
With some changes in #jigs answer i got it working and posting may be it can help others like me
1) Root layout as normal in my case Relative layout. Then scroll view inside scroll view take a Linear layout where specify edit text + image View. Then bottom button.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize"
android:background="#android:color/white"
android:orientation="vertical">
<ScrollView
android:id="#+id/scrollViewNotScrollable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/user_name_container">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
>
<EditText
android:id="#+id/input_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#00000000"
android:ellipsize="start"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="start|center_vertical"
android:hint="#string/feed_hint"
android:imeActionLabel="Submit"
android:imeOptions="actionSend"
android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
android:maxLines="5"
android:minLines="3"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="25dp"
android:textColor="#color/feed_sub_color"
android:textColorHint="#color/light_gray"
android:textCursorDrawable="#null" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<!--<ScrollView
android:id="#+id/scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isScrollContainer="false"
android:padding="4dp"
android:layout_centerHorizontal="true"
>-->
<ImageView
android:id="#+id/imgPreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:background="#android:color/white"
android:elevation="5dp"
android:padding="4dp"
android:visibility="gone" />
<!--</ScrollView>-->
<ImageView
android:id="#+id/close_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/imgPreview"
android:layout_marginLeft="-45dp"
android:layout_marginTop="-20dp"
android:layout_toRightOf="#+id/imgPreview"
android:elevation="5dp"
android:paddingBottom="15dp"
android:src="#drawable/closeimage"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/user_name_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:fitsSystemWindows="true">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<EditText
android:id="#+id/feed_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#null"
android:ellipsize="end"
android:fontFamily="san-serif-condensed"
android:padding="12dp"
android:singleLine="true"
android:text="sherry's phone"
android:textColor="#android:color/black"
android:textSize="#dimen/feed_name_size"
android:visibility="gone" />
<TextView
android:id="#+id/feed_user_name_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#null"
android:ellipsize="end"
android:fontFamily="san-serif-condensed"
android:padding="12dp"
android:paddingLeft="20dp"
android:singleLine="true"
android:text="sherry's phone"
android:textColor="#android:color/black"
android:textSize="#dimen/feed_name_size" />
<ImageView
android:id="#+id/edit_name"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_gravity="end"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:scaleType="centerInside"
android:src="#drawable/editname" />
<Button
android:id="#+id/done"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_corner_update_block"
android:fontFamily="san-serif-medium"
android:text="Done"
android:textColor="#android:color/white"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
2)android:windowSoftInputMode="adjustResize" in your manifest.xml
3) disable scroll in java code (optional)
mScrollView.setOnTouchListener( new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event)
{
return true;
}
});