Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当键盘向上时,ListView被向上推_Java_Android_Listview_Android Edittext_Android Softkeyboard - Fatal编程技术网

Java 当键盘向上时,ListView被向上推

Java 当键盘向上时,ListView被向上推,java,android,listview,android-edittext,android-softkeyboard,Java,Android,Listview,Android Edittext,Android Softkeyboard,我遇到了这个问题: 当我聚焦编辑文本时,键盘会弹出(当然),但它也会将我的列表视图向上推而不是向上推。 这不需要选择编辑文本: ---item 1--- ---item 2--- ---item 3--- ---item 4--- ---EditText--- 选择EditText后: ---item 3--- ---item 4--- ---EditText--- ---Keyboard--- 现在,项目1和2已退出屏幕(位于顶部) 但我试图实现的是: --

我遇到了这个问题:

当我聚焦编辑文本时,键盘会弹出(当然),但它也会将我的列表视图向上推而不是向上推。
这不需要选择编辑文本:

---item 1---  
---item 2---  
---item 3---  
---item 4---  
---EditText---
选择EditText后:

---item 3---  
---item 4---  
---EditText---  
---Keyboard---  
现在,项目1和2已退出屏幕(位于顶部)

但我试图实现的是:

---item 1---  
---item 2---  
---EditText---  
---Keyboard---  
只有当我在清单中得到这个信息时才会发生这种情况:
android:windowSoftInputMode=“adjustPan”

我使用这一行是因为当我不使用这一行时,会发生以下情况:

---item 1---  
---item 2---   
---item 3---  
---keyboard---  
现在编辑文本在键盘后面

我希望你们能得到一些关于如何获得的建议:

---item 1---  
---item 2---  
---EditText---  
---Keyboard---  
XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="424dp" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:layout_weight="0.66" >



    <EditText
        android:id="@+id/txt_zoeken"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:ems="10" >

        <requestFocus />
    </EditText>



    <Button
        android:id="@+id/btn_zoeken"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:onClick="btn_zoeken"
        android:text="Button" />

</RelativeLayout>

试试这个(在ScrollView中包装您的编辑文本),当我遇到同样的情况时,它对我很有效

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="424dp" />

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_weight="0.66" >

        <EditText
            android:id="@+id/txt_zoeken"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:ems="10" >

            <requestFocus />
        </EditText>

        <Button
            android:id="@+id/btn_zoeken"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:onClick="btn_zoeken"
            android:text="Button" />
    </RelativeLayout>
</ScrollView>


此EditText是否是您的ListView的一部分???@wasaig否,它处于不同的布局(添加了XML)@Carnal我也尝试过,但后来您发现我的
EditText
位于我的键盘后面。没有变化,仍然是第四种情况。尝试使用android:WindowsOfInputMode=“adjustResize”而不是android:WindowsOfInputMode=“adjustPan”尝试了同时使用和不使用,但它与我在问题中解释的一样。使用adjustResize,情况4仍然没有改变。