As the title suggests, when I add android:windowSoftInputMode="adjustPan"
in my Manifest, as well as inputType="textPassword"
in my password EditText
, the adjustPan
still covers a portion of the editText
. For reference, here is the layout code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@color/background"
tools:context=".home.LoginActivity">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginEnd="40dp"
android:layout_marginStart="40dp">
<ImageView
android:id="@+id/log_in_launcher_icon"
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_centerHorizontal="true"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher_logo" />
<RelativeLayout
android:id="@+id/log_in_rellay1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/log_in_launcher_icon"
>
<LinearLayout
android:id="@+id/log_in_linlay1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto_light"
android:text="@string/email_title"
android:textColor="@color/dirtyWhite"
android:textSize="15sp" />
<EditText
android:id="@+id/log_in_et_email"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/et_bg"
android:inputType="textEmailAddress"
android:fontFamily="@font/roboto_light"
android:paddingEnd="15dp"
android:paddingStart="15dp"
android:textColor="@color/dirtyWhite"
android:textSize="15sp"
android:nextFocusForward="@+id/log_in_et_password"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto_light"
android:text="@string/password_title"
android:textColor="@color/dirtyWhite"
android:textSize="15sp" />
<EditText
android:id="@+id/log_in_et_password"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/et_bg"
android:inputType="textPassword"
android:fontFamily="@font/roboto_light"
android:paddingEnd="15dp"
android:paddingStart="15dp"
android:textColor="@color/dirtyWhite"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/log_in_pb"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/log_in_linlay1"
android:layout_centerHorizontal="true"
android:visibility="gone"/>
<Button
android:id="@+id/log_in_btn_log_in"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_below="@+id/log_in_linlay1"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:background="@drawable/btn_bg"
android:fontFamily="@font/roboto_light"
android:paddingEnd="70dp"
android:paddingStart="70dp"
android:text="@string/log_in_title"
android:textColor="@color/dirtyWhite"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/log_in_rellay2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
>
<Button
android:id="@+id/log_in_btn_sign_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:fontFamily="@font/roboto_light"
android:text="@string/log_in_sign_up"
android:textAllCaps="true"
android:textColor="@color/dirtyWhite"
android:textSize="16sp" />
<Button
android:id="@+id/log_in_btn_forgot_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@color/transparent"
android:fontFamily="@font/roboto_light"
android:text="@string/log_in_forgot_password"
android:textAllCaps="true"
android:textColor="@color/dirtyWhite"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
I'd highly appreciate if somebody could help me solve this issue.
This is a normal behavior of soft keyboard. It's just responsible for text part of EditText
not other part of view.
Here is a code snippet I wrote before It helps you to scroll up your view in you custom height.
final View root = findViewById(android.R.id.content);
root.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
Rect r = new Rect();
{
root.getWindowVisibleDisplayFrame(r);
}
@Override
public void onGlobalLayout() {
Rect r2 = new Rect();
root.getWindowVisibleDisplayFrame(r2);
int keyboardHeight = r.height() - r2.height();
if (keyboardHeight > 100) {
root.scrollTo(0, keyboardHeight);
}
else {
root.scrollTo(0, 0);
}
}
});
root.scrollTo(0, keyboardHeight);
in this line you can change 0
and keyboardHeight
to your custom values.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.