[英]EditText over ListView when KeyBoard appears
So, I'm developing an application that have a Listview, an EditText and a Button below the ListView. 因此,我正在开发一个具有Listview,EditText和ListView下面的Button的应用程序。 Like this printscreen: 像这样的打印屏幕:
The problem is: When I click in the EditText, the EditText rises and stay ahead my Listview, like this printscreen: 问题是:当我单击EditText时,EditText上升并保持在Listview的前面,如下图所示:
In my Mainfest I already add the windowSoftInputMode="AdjustResize" and windowSoftInputMode="adjustPan" and any works. 在我的Mainfest中,我已经添加了windowSoftInputMode =“ AdjustResize”和windowSoftInputMode =“ adjustPan”以及任何其他作品。
This is my XML: 这是我的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>
Can anyone help me with this problem? 谁能帮助我解决这个问题? Thanks for any help guys! 感谢您的帮助!
Try This. 尝试这个。 And Add margin according to your need. 并根据您的需要增加边距。
I tested this in my mobile. 我在手机上对此进行了测试。
<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>
add RequestFocus below This snippet 在此代码段下方添加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.