android – 显示软键盘时向上移动布局

在编辑文本获得焦点后出现软键盘时,我正在尝试调整布局.现在,如果我有很多编辑文本并且键盘出现,则隐藏最后一个编辑文本,我无法向上滚动.

这就是我的布局构建方式:

模板:

<LinearLayout>
    <LinearLayout>
        // header 1
    </LinearLayout>
    <LinearLayout>
        // header 1
    </LinearLayout>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:orientation="vertical">
        // where I inflate view_1
    </LinearLayout>
    <LinearLayout>
        // footer
    </LinearLayout>
</LinearLayout>

查看(view_1):

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true">
        <LinearLayout>
            // ...
        </LinearLayout>
        <LinearLayout>
            // ...
        </LinearLayout>
        <LinearLayout>
            <TextView/>
            <EditText/>
            <TextView/>
            <EditText/>
            <TextView/>
            <EditText/>
            <TextView/>
            <EditText/>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

我已经尝试了android的各种组合:windowSoftInputMode(在manifest.xml上并以编程方式).我试图在滚动视图上设置android:isScrollContainer =“false”,但没有.

我也尝试了这个answer,在我的滚动视图中放置了一个GlobalLayoutListener,但是当键盘出现时没有调用onGlobalLayout.并且isKeyboardShown总是错误的.

解决方法

我找到的最佳解决方案是在活动中添加adjustpan属性<> manifest.xml文件中的标记.

<activity
   android:name="MyActivity"
   android:windowSoftInputMode="adjustPan"/>

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...