简体   繁体   English

键盘弹出时,按钮失去焦点

[英]button looses focus when keypad comes up

I have edit text and a button next to it at the bottom of the screen and at the top of the screen is list view ,When I click on the edit text and the keyboard comes up under the button and edit text ,these both come over the list view and button is also not click able as far as the keyboard is open. 我在屏幕底部有一个编辑文本,旁边有一个按钮,屏幕顶部是列表视图,当我单击编辑文本时,键盘出现在按钮下方并编辑文本,这两个按钮都出现了只要键盘处于打开状态,列表视图和按钮也无法单击。 Please help.! 请帮忙。! This is my Xml. 这是我的Xml。

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent" >

      <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="86dp"
    android:layout_gravity="bottom" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="Send" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/button1"
        android:ems="10" />

  </RelativeLayout>

  <ListView
      android:id="@android:id/list"
      android:layout_width="match_parent"
      android:layout_height="317dp" 
    >

  </ListView>

        </FrameLayout>

That is really odd behavior. 那真是奇怪的行为。 With your layout, I got the same results. 使用您的布局,我得到了相同的结果。 I'm not exactly sure why that button becomes unclickable. 我不确定为什么该按钮无法单击。

However, if you don't absolutely have to have the FrameLayout that your layout is obviously contained in, then I suggest using the following: 但是,如果您不必绝对要在其中包含布局的FrameLayout,那么建议您使用以下代码:

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

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10" />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Send" />

    </LinearLayout>

</LinearLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM