简体   繁体   English

显示键盘时如何向上滚动屏幕?

[英]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.

相关问题 显示键盘时我可以防止键盘将其向上推吗 - Can i prevent the keyboard to push things up when it's shown 出现键盘时向上滚动屏幕 - Scroll the screen up when keyboard appears RelativeLayout问题。 显示键盘时ImageView向上滚动 - RelativeLayout problem. ImageView scroll up when keyboard shown 如何用滚动拇指上下滚动屏幕? - How can I make the screen scroll up and down with the scroll thumb? 键盘打开时如何将屏幕向上推,以便用户看到自动完成? - How can I push the screen up when the keyboard is opened so the user would see the auto complete? 当显示软键盘时,无法让ScrollView滚动 - Can not get ScrollView to scroll when soft keyboard is shown 如何使用FULL_SCREEN在活动中显示键盘时如何向上滚动布局 - how to scroll up layout when keyboard visible in activity with FULL_SCREEN 当虚拟键盘出现在本机反应中时如何自动向上滚动屏幕(在 android 上) - How to auto scroll the screen up when virtual keyboard appears in react native (on android) 显示softinputkeyboard时如何向上滚动滚动视图的子级 - How to scroll up a child of a scroll view when softinputkeyboard is shown 键盘显示时如何向上移动整个布局? - How to move up the whole layout when keyboard shown?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM