[英]layout is not moving up when keyboard is shown
我的活动中有一个NestedScrollView
,其中包含大约7-8个编辑文本,并且在显示键盘时需要它们向上移动。 我正在这样做,但是没有用
android:windowSoftInputMode="adjustPan|adjustResize"
activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:focusableInTouchMode="true"
tools:context="com.amir_p.cafino.LoginActivity">
<ImageView
android:id="@+id/back_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grayTransparent" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:id="@+id/signup_layout"
android:fillViewport="true"
android:layout_height="wrap_content"
android:visibility="gone">
<LinearLayout
android:id="@+id/register_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="16dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:hint="نام و نام خانوادگی"
android:textColorHint="@color/white">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/white" />
</android.support.design.widget.TextInputLayout>
[...]
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
尝试为您的滚动视图添加android:fillViewport="true"
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:visibility="visible">
并在清单中添加:
android:windowSoftInputMode="stateVisible|adjustResize"
您可以通过编程方式关闭填充屏幕模式:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
全屏模式不会调整大小。
或者您可以使用其他主题: android:theme="@android:style/Theme.Black.NoTitleBar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.