【问题标题】:Softkeyboard opening in DIALOG NOT ACTIVITY will led layout to upper out of the screen. I want my top layout fix on the Top of the screen [duplicate]在 DIALOG NOT ACTIVITY 中打开软键盘将导致布局到屏幕上方。我希望我的顶部布局修复在屏幕顶部 [重复]
【发布时间】:2014-08-03 18:48:31
【问题描述】:

这是我的对话框布局

<?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 Relative Layout 这就像一个操作栏离开屏幕。请帮助我解决此问题的另一种选择或任何解决方案..

这是我的源代码..

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);

【问题讨论】:

  • 我已经在我的活动中添加了这个,但我已经将它作为对话框打开,并且在对话框中我希望在布局顶部修复上视图....其他布局可以滑动不是问题

标签: android android-layout dialog


【解决方案1】:

在 Manifest 文件中试试这个

 android:windowSoftInputMode="adjustResize"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-01
    • 2015-06-24
    • 2015-04-30
    相关资源
    最近更新 更多