0

My question is: If I set my parent layout to wrap_content, and the child view changes size somewhere during the execution, should my parent layout also change size?

I assumed yes, but my dialog behavior shows otherwise. That being said, it's very possible that something else is happening (I am not original writer).

More context: I have an alert dialog that contains two buttons and an edittext. The edittext will expand with every line until it reaches five lines.

Expected: Dialog expands when the edittext expands

Actual: Dialog does not expand; edittext expands and pushes buttons down such that they are clipped

Here is a simplified snippet to show what I am talking about

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
  <EditText
  android:id="@+id/inputbox"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"/>

  <LinearLayout
  android:orientation="horizontal"
  android:layout_width="wrap_content"
  android:layout_height="@dimen/someheight"
  android:gravity="center"
  android:layout_gravity="center_horizontal" >

  <Button
      android:id="@+id/negative_button"
      android:layout_width="@dimen/somewidth"
      android:layout_height="match_parent"
      android:text="@string/TXT_CANCEL"/>

  </LinearLayout>
</LinearLayout>
Eric S.
  • 1,502
  • 13
  • 31
  • 2
    `Dialog` is a special and convoluted case: http://stackoverflow.com/questions/14907104/alertdialog-with-custom-view-resize-to-wrap-the-views-content – tachyonflux May 07 '15 at 20:45
  • thanks for the tip, this is exactly what I couldn't find. – Eric S. May 07 '15 at 21:02

0 Answers0