当软键盘可见时,按钮OnClickListener不起作用

时间:2018-01-08 18:54:48

标签: android android-layout buttonclick

启动活动后,系统会提示用户输入其电子邮件。可以看到TextViewButton以及键盘。但是,当用户点击按钮时,它不起作用 - 而键盘消失,然后用户必须再次点击按钮才能工作。因此,需要两次用户点击才能使此按钮生效。当键盘可见时,我们如何让按钮监听器工作?

以下是我在manifest中提出的代码:

android:windowSoftInputMode="adjustResize"

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    style="@style/provisioning_background_color">


<!-- https://stackoverflow.com/questions/15323758/android-how-to-push-button-above-soft-keyboard -->

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/btn_next_email">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="center"
        android:layout_gravity="center">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="@dimen/sign_in_logo_height"
            android:src = "@drawable/bg_form_top"
            android:layout_marginRight="@dimen/sign_in_logo_top_margin"/>

        <Button
            android:id="@+id/btn_already_have_account"
            android:textAllCaps="false"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="?android:attr/borderlessButtonStyle"
            android:textColor="@color/app_text_color"
            android:textSize="17dp"
            android:text="@string/already_have_account"/>

        <EditText
            android:id="@+id/text_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textEmailAddress"
            android:textColor="@color/app_text_color"
            android:gravity="center"
            android:textColorHint="@color/app_text_color"
            android:hint="Enter Email"
            android:layout_marginTop="20dp"/>
    </LinearLayout>
</ScrollView>

<Button
    android:id="@+id/btn_next_email"
    android:layout_width="match_parent"
    android:layout_height="@dimen/create_account_buttons"
    android:textSize="@dimen/create_account_buttons_txt_size"
    android:layout_alignParentBottom="true"
    android:layout_margin="10dp"
    android:text="NEXT"
    style="@style/provisioning_buttons"
    android:nextFocusForward="@+id/text_email"/>

0 个答案:

没有答案
相关问题