启用键盘时,如何将Entair屏幕移动



我想在键盘打开时,要向上滚动entair屏幕。如何做?

https://www.screencast.com/t/34jwvngldybu

在清单文件中将android:windowSoftInputMode="adjustPan|adjustResize"与活动标签应用。

android:windowSoftInputMode="adjustPan|adjustResize"

并在LinearLayoutScrollView&中放置完整的布局。定义

layout_height="0dp"
layout_weight="1"

注意:没有视图具有参数layout_height="match_parent"

我也遇到了同样的问题

<activity
        android:name=".activities.YOURACTIVITY"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="adjustResize|stateVisible"/>

如果要在开始活动中出现键盘,请使用stateVisible,否则使用stateHidden

这里最重要的值是adjustResize。这将使整个UI转移以为软键提供空间。

最新更新