[英]How can I scroll up screen when the keyboard is shown?
I want to be able to scroll up the login screen when the keyboard is shown. 我希望能够在显示键盘时向上滚动登录屏幕。 I don't use ScrollView, I only have a RelativeLayout with an ImageView and another LinearLayout inside it.
我不使用ScrollView,只有一个带有ImageView的RelativeLayout和其中的另一个LinearLayout。 I've tried adding whats below in AndroidManifest but didn't work.
我试过在AndroidManifest中添加以下内容,但没有用。
android:windowSoftInputMode="adjustResize"
Place your root-layout (the Relative layout in your case) inside a scrollview
(let's say it's called scrollview1), and when the keyboard appears, run the following code: 将您的根布局(在您的情况下为相对布局)放在
scrollview
(假设它称为scrollview1)内,并在出现键盘时运行以下代码:
scrollview1.post(new Runnable() {
@Override
public void run() {
scrollview1.fullScroll(View.FOCUS_UP);
}
});
Edit: Please note that scrollviews can have only one child, so make sure of that. 编辑:请注意,scrollviews只能有一个孩子,因此请确保这一点。
While adding activity in manifest add 在清单中添加活动时
<activity
android:name=".Activities.InputsActivity"
...
android:windowSoftInputMode="adjustPan"
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.