簡體   English   中英

出現鍵盤時,ListView上的EditText

[英]EditText over ListView when KeyBoard appears

因此,我正在開發一個具有Listview,EditText和ListView下面的Button的應用程序。 像這樣的打印屏幕: 在此處輸入圖片說明

問題是:當我單擊EditText時,EditText上升並保持在Listview的前面,如下圖所示:

在此處輸入圖片說明

在我的Mainfest中,我已經添加了windowSoftInputMode =“ AdjustResize”和windowSoftInputMode =“ adjustPan”以及任何其他作品。

這是我的XML:

<RelativeLayout     xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="400dp"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    android:ems="10"
    android:id="@+id/editText"
    android:hint="Senha"
    android:textColor="#000000"
    android:layout_marginBottom="22dp"
    android:layout_above="@+id/button"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Conectar"
    android:id="@+id/button"
    android:textColor="#000000"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="39dp" />

    <ListView
        android:layout_width="330dp"
        android:layout_height="260dp"
        android:id="@+id/listView"
        android:background="@drawable/border"
        android:stackFromBottom="true"
        android:transcriptMode="normal"
        android:layout_marginLeft="63dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />
              </RelativeLayout>

誰能幫助我解決這個問題? 感謝您的幫助!

嘗試這個。 並根據您的需要增加邊距。
我在手機上對此進行了測試。

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/border" >
        </ListView>
    </LinearLayout>

    <EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="22dp"
        android:ems="10"
        android:hint="Senha"
        android:inputType="textPassword"
        android:textColor="#000000" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="39dp"
        android:text="Conectar"
        android:textColor="#000000" />

</LinearLayout>

在此代碼段下方添加RequestFocus

 <ListView
        android:layout_width="330dp"
        android:layout_height="260dp"
        android:id="@+id/listView"
        android:background="@drawable/border"
        android:stackFromBottom="true"
        android:transcriptMode="normal"
        android:layout_marginLeft="63dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />
    <RequestFocus/> 
</Relativelayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM