软键盘隐藏了alertdialog的一部分

时间:2014-11-23 18:15:01

标签: android android-activity alertdialog android-alertdialog android-softkeyboard

我有一个带有表单的alertDialog。当我将焦点放在该表单上的editText时,软键盘会隐藏表单中的一部分。我试过android:windowSoftInputMode =" adjustPan"在我的主要活动和形式的布局上,但没有奏效。有什么想法吗?

这是我的主要活动布局:

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

</LinearLayout>

这是我的表单布局:

<ScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:fillViewport="true">
   <RelativeLayout 
       android:layout_width="fill_parent"
       android:layout_height="wrap_content" android:background="#fff">
   ...
   ...
   </RelativeLayout>
</ScrollView>

以下是我如何创建带有表单的alertDialog(layoutId参数是上面的R.layout.form):

public static AlertDialog showPopupForm(Activity activity, int layoutId, OnClickListener submitAction){
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    final View view = activity.getLayoutInflater().inflate(layoutId, null);
    builder.setCancelable(true);
    builder.setView(view);
    builder.setPositiveButton("Submit", submitAction);
    builder.setNegativeButton("Cancel", null);
    AlertDialog dialog = builder.create();
    dialog.show();
    return dialog;
}

由于

0 个答案:

没有答案