在包含ScrollView的活动中强制调整adjustPan

时间:2011-05-24 18:20:57

标签: android android-layout

我的布局如下:

<RelativeLayout>
    <RelativeLayout>
    </RelativeLayout>
    <ViewFlipper>
        <ScrollView>
            <LinearLayout>
                <EditText />
            </LinearLayout>
        </ScrollView>
    </ViewFlipper>
    <RelativeLayout>
    </RelativeLayout>
</RelativeLayout>

当专注于中间的EditText时,软键盘会按预期弹出,但即使清单中有android:windowSoftInputMode="adjustPan",它也会一直调整布局大小。

调整大小的问题是只有ScrollView会缩小,而且RelativeLayouts的上方和下方都完好无损,这几乎可以完全掩盖EditText。

我已经尝试在显示键盘时隐藏RelativeLayouts(这是另一个悲伤的故事),但adjustPan听起来更合适。但它对此活动没有影响。

尽管存在ScrollView,我怎样才能强制adjustPan工作?

更新

所以不会让我回答我自己的问题,但解决办法是在ScrollView上设置android:isScrollContainer="false"

2 个答案:

答案 0 :(得分:0)

好问题主要是开发人员做同样的事情,但这不是你需要做的正确方法。这对你有帮助。

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical">


<ViewFlipper>
    <ScrollView
      android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       >
        <LinearLayout
          android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:orientation="vertical"
        >
            <EditText />
        </LinearLayout>
    </ScrollView>
</ViewFlipper>
<LinearLayout> 

你应该将LinearLayout作为垂直或水平视图的方向,你从来没有创建调整问题。这很简单。

答案 1 :(得分:-2)

在你的清单中尝试这个活动标签:

android:windowSoftInputMode="stateVisible|adjustPan"
相关问题