出现键盘时如何使android视图可滚动? [英] how to make an android view scrollable when the keyboard appears?

查看:34
本文介绍了出现键盘时如何使android视图可滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些字段(姓名、电子邮件、密码、注册按钮)的视图:

I have a view with some fields (name, email, password, register button) :

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ViewFlipper
        android:id="@+id/viewflipper"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        //Layouts

    </ViewFlipper>

</ScrollView>

当我聚焦编辑文本字段时,键盘出现并覆盖视图上的较低字段.所以当键盘存在时我看不到它们.我想知道如何使视图可滚动,以便我可以看到较低的字段.此外,如何使视图自动滚动以使聚焦的字段可见.

When I focus an edittext field, the keyboard appears and is overlaying the lower fields on the view. So I can't see them when the keyboard is present. I would like to know how to make the view scrollable so that I can see the lower fields. And additionally, how to make the view scroll automatically to make the focused field visible.

推荐答案

您需要在 AndroidManifest.xml 文件中为您的活动包含 android:windowSoftInputMode="adjustResize" 属性 - 然后 Android 应该自动为您调整大小:

You need to include android:windowSoftInputMode="adjustResize" attribute for your activity in the AndroidManifest.xml file - and then Android should do the resizing for you automatically:

<activity android:name="..."
          ...
          android:windowSoftInputMode="adjustResize">
    ...
/>

这篇关于出现键盘时如何使android视图可滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆