DIALOG NOT ACTIVITY中的软键盘打开将导致屏幕上方的布局。我希望我的顶部布局修复在屏幕顶部

时间:2014-06-13 08:57:42

标签: android android-layout dialog

这是我的对话框布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:isScrollContainer="false"
android:orientation="vertical" >

<RelativeLayout
    android:id="@+id/topbar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_gravity="top"
    android:background="@drawable/android_add_note"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/cancelNoteButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:background="@drawable/android_back" />

    <ImageView
        android:id="@+id/saveNoteButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/android_done" />
</RelativeLayout>

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/topbar"
    android:fadingEdge="none"
    android:padding="10dp"
    android:scrollbars="none" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/top"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/addNoteTextView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/android_contentbg"
            android:ellipsize="end"
            android:gravity="top"
            android:maxLines="4"
            android:padding="15dp"
            android:textColor="@android:color/black"
            android:textSize="@dimen/text_size_small" />

        <EditText
            android:id="@+id/addNoteEditText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@android:color/transparent"
            android:ellipsize="start"
            android:gravity="top"
            android:isScrollContainer="false"
            android:minLines="5"
            android:textColor="@color/light_blue"
            android:textSize="@dimen/text_size" />
    </LinearLayout>
</ScrollView>
</RelativeLayout>

现在,当我在editText中输入长文本时,它会引导我的 topbar 相对布局,就像屏幕上的操作栏一样。请帮助我解决这个或任何解决方案的另一种选择..

这是我的源代码..

final Dialog addNoteDialog;
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
            EReaderConstants.FULL_SCREEN_ON_OFF, true) == false) {
        addNoteDialog = new Dialog(this,
                android.R.style.Theme_Translucent_NoTitleBar);
    } else {
        addNoteDialog = new Dialog(this,
                android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
    }
    addNoteDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Window window = addNoteDialog.getWindow();
    window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    window.setGravity(Gravity.CENTER);
    addNoteDialog.setContentView(R.layout.dialog_add_note);
    addNoteDialog.setCancelable(false);

1 个答案:

答案 0 :(得分:0)

在清单文件中尝试此操作

 android:windowSoftInputMode="adjustResize"