Android软键盘在动态添加布局的情况下覆盖edittext

时间:2017-08-17 09:33:43

标签: android android-softkeyboard

<activity
        android:name=".UI.AuthenticationActivity"
        android:windowSoftInputMode="adjustPan"
        android:screenOrientation="portrait"/>

活动标签(清单)中的上述代码适用于活动布局和对话框。但是当我动态地将表单布局添加到布局时,然后在该布局中,edittext仍保留在软键盘下。

主要布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_authentication"
android:layout_width="match_parent"
android:isScrollContainer="true"
android:layout_height="match_parent"
android:background="@drawable/girl_running_background">

   //Main Layout Code here (Form and stuffs)
</RelativeLayout>

动态添加布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sponsorDetailLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:clickable="true"
android:orientation="vertical">


    <EditText
        android:id="@+id/et_Name"
        android:layout_width="match_parent"
        android:layout_height="@dimen/edit_text_height"
        android:inputType="text"
        android:imeOptions="actionNext"
        />

        <EditText
        android:id="@+id/et_Password"
        android:layout_width="match_parent"
        android:layout_height="@dimen/edit_text_height"
        android:inputType="text"
        android:imeOptions="actionNext"
        />
        <EditText
        android:id="@+id/et_Email"
        android:layout_width="match_parent"
        android:layout_height="@dimen/edit_text_height"
        android:inputType="text"
        android:imeOptions="actionNext"
        />

</LinearLayout>

在主布局上添加动态布局的方法。

private void signUpDialog() {
    view = getLayoutInflater().inflate(R.layout.signup_view, authenticationRelativeLayout, false);//authentication 
    signUpLinearLayout = (LinearLayout) view.findViewById(R.id.signUpLinearLayout);
    fullNameEditText = (EditText) view.findViewById(R.id.et_Name);
    passwordEditText = (EditText) view.findViewById(R.id.et_Password);
    emailEditText = (EditText) view.findViewById(R.id.et_Email);

    view.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    //Layout added here to main layout
    authenticationRelativeLayout.addView(view);

}

0 个答案:

没有答案