0

I'm having trouble with the message of a dialog.

Everything works fine until I want to type information in the edittext and the keyboard pops up - then the second (and last) line of the message of the dialog is cut to half..

Looks dialog looks like

Icon and Title:


Message line 1

Message line 2 (<- half visibile with keyboard)

ScrollView with some edittexts

Negative button | Positive button

Edit: Code

LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(mContext.LAYOUT_INFLATER_SERVICE);
            View viewGroup = inflater.inflate(R.layout.layout_dialog_daily_report, null);
            ScrollView layout = (ScrollView) viewGroup.findViewById(R.id.dialog_parent);
            final EditText 1 = (EditText) viewGroup.findViewById(R.id.dialog_1);
            final EditText 2 = (EditText) viewGroup.findViewById(R.id.dialog_2);
            final EditText 3 = (EditText) viewGroup.findViewById(R.id.dialog_3);
            final EditText 4 = (EditText) viewGroup.findViewById(R.id.dialog_4);

            AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
            builder.setIcon(R.drawable.icon);
            builder.setTitle(R.string.dialog_title);
            builder.setMessage(R.string.dialog_message);
            builder.setView(layout);
            builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });

            builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            AlertDialog dialog = builder.create();
            dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
            dialog.show();

Layout:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialog_parent"
android:margin="7dp"
android:layout_width="match_parent"
android:layout_height="match_parent" >

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.6"
            android:ellipsize="end"
            android:text="@string/dialog_1" />

        <EditText
            android:id="@+id/dialog_1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.4" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.6"
            android:ellipsize="end"
            android:text="@string/dialog_2" />

        <EditText
            android:id="@+id/dialog_2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.4" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.6"
            android:ellipsize="end"
            android:text="@string/dialog_3" />

        <EditText
            android:id="@+id/dialog_3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.4" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.6"
            android:ellipsize="end"
            android:text="@string/dialog_4" />

        <EditText
            android:id="@+id/dialog_4"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.4" />
    </LinearLayout>
</LinearLayout>

enter image description here

As you can see the buttons are not visible, I dont know why the scrollview isnt scrollable anymore How can I prevent that the Dialog.setMessage text is cut off on showing the keyboard?

Zuop
  • 584
  • 5
  • 7
  • 21

2 Answers2

0

add next line into your Manifest:

android:windowSoftInputMode="adjustResize"

Amy
  • 4,034
  • 1
  • 20
  • 34
  • well I tried that, but nothing changes. The Dialog is shown in a Listener Class onClick if that helps. Anyway, the Scrollview is not scrollable anymore and I dont know why I changed everything back.. now the buttons are cut off :D – Zuop Oct 09 '14 at 07:53
  • could you share Screenshot ? – Amy Oct 09 '14 at 07:54
  • you got the solution? – Amy Oct 09 '14 at 07:58
  • not yet, but the topic is on page over9000 now, anyway thanks for help :) – Zuop Oct 09 '14 at 08:28
0

I believe the errors are mostly in xml,try removing android:elipsize,maybe giving the layout_width's a value other that 0,you can try

vera
  • 3
  • 3