title: Android Lollipop Soft Keyboard Hides User Inputs in DialogFragment
body: <p>I am writing my first real Android application. I have an Android <code>DialogFragment</code> that I am displaying to allow users to add or edit details of a selected item. The DialogFragment pops up and displays fine in full screen mode. However, on the Lollipop emulator when I click on <code>EditText</code> widgets that are lower on the screen, the soft keyboard covers up the widget, rather than scrolling the screen up so that the user may see what they are typing. I do NOT experience this behavior in the pre-Lollipop emulator. On the KitKat emulator, the screen adjusts so that the <code>EditText</code> is still visible. StackOverflow will not let me post pictures yet. So, you'll have to use your imagination. :-( I have tried different ways to overcome this issue. Unfortunately, none have worked for Lollipop.</p>
  
  <p><strong>UPDATE</strong> - I have tested this on a Sony Xperia Z3 Compact running Android 5.0.2, and the <code>DialogFragment</code> does not scroll or adjust the screen when selecting the lower <code>EditText</code> widgets.</p>
  
  <p>Here are the styles in use:</p>
  
  <pre><code>&lt;!-- Base application theme. --&gt;
  &lt;style name="AppTheme" parent="AppTheme.Base"&gt;
      &lt;!-- Customize your theme here. --&gt;
  &lt;/style&gt;
  
  &lt;style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"&gt;
      &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
      &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
      &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
      &lt;item name="android:textColorPrimary"&gt;@color/colorPrimaryText&lt;/item&gt;
      &lt;item name="android:textColorSecondary"&gt;@color/colorSecondaryText&lt;/item&gt;
      &lt;item name="android:dialogTheme"&gt;@style/DialogTheme&lt;/item&gt;
      &lt;item name="android:actionBarStyle"&gt;@style/AppActionBarTheme&lt;/item&gt;
      &lt;item name="actionBarStyle"&gt;@style/AppActionBarTheme&lt;/item&gt;"
      &lt;item name="actionBarTheme"&gt;@style/AppActionBarTheme&lt;/item&gt;
      &lt;item name="actionBarPopupTheme"&gt;@style/AppActionBarOverflowMenuTheme&lt;/item&gt;
      &lt;item name="windowActionModeOverlay"&gt;true&lt;/item&gt;
  &lt;/style&gt;
  
  &lt;style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog"&gt;
      &lt;item name="android:clickable"&gt;true&lt;/item&gt;
      &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
      &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
      &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
      &lt;item name="android:windowSoftInputMode"&gt;stateHidden|adjustResize&lt;/item&gt;
      &lt;item name="windowActionModeOverlay"&gt;true&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>As you can see in the <code>DialogTheme</code>, I have included the <code>android:windowSoftInputMode</code> attribute. I have also tried using that attribute in the AndroidManifest.xml file under the Activity that ultimately contains the <code>DialogFragment</code>. Here is the XML layout file for the <code>DialogFragment</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;com.ahappydevelopment.android.fishtales.views.LogEditView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_marginTop="@dimen/dialog_margin_top"
      android:background="@color/background_material_light"
      android:theme="@style/DialogTheme"&gt;
  
      &lt;include
          android:id="@+id/app_bar"
          layout="@layout/app_bar_edit" /&gt;
  
      &lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_below="@id/app_bar"&gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:paddingBottom="@dimen/activity_vertical_margin"
              android:paddingLeft="@dimen/activity_horizontal_margin"
              android:paddingRight="@dimen/activity_horizontal_margin"
              android:paddingTop="@dimen/activity_vertical_margin"&gt;
  
              &lt;Button
                  android:id="@+id/btnCatchDate"
                  style="?android:attr/borderlessButtonStyle"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:layout_alignParentTop="true"
                  android:textAllCaps="false" /&gt;
  
              &lt;Button
                  android:id="@+id/btnCatchTime"
                  style="?android:attr/borderlessButtonStyle"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentEnd="true"
                  android:layout_alignParentRight="true"
                  android:layout_alignParentTop="true"
                  android:textAllCaps="false" /&gt;
  
              &lt;EditText
                  android:id="@+id/editLatitudeLabel"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:layout_below="@id/btnCatchDate"
                  android:ems="10"
                  android:hint="@string/label_latitude"
                  android:inputType="numberDecimal" /&gt;
  
  
              &lt;EditText
                  android:id="@+id/editLongitudeLabel"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:layout_below="@id/editLatitudeLabel"
                  android:ems="10"
                  android:hint="@string/label_longitude"
                  android:inputType="numberDecimal" /&gt;
  
              &lt;ImageView
                  android:id="@+id/imgCatchPicture"
                  android:layout_width="75dp"
                  android:layout_height="75dp"
                  android:layout_alignParentEnd="true"
                  android:layout_alignParentRight="true"
                  android:layout_alignTop="@id/editLatitudeLabel"
                  android:background="@android:color/darker_gray"
                  android:contentDescription="@string/imgcatchpicture_contentdescription"
                  android:scaleType="centerInside"
                  android:src="@android:drawable/ic_menu_camera" /&gt;
  
              &lt;Spinner
                  android:id="@+id/spinnerLocation"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:layout_below="@id/editLongitudeLabel" /&gt;
  
              &lt;TextView
                  android:id="@+id/txtFishHeader"
                  style="?android:attr/listSeparatorTextViewStyle"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:layout_below="@id/spinnerLocation"
                  android:text="@string/section_fish" /&gt;
  
              &lt;Spinner
                  android:id="@+id/spinnerSpeciesType"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:layout_below="@id/txtFishHeader" /&gt;
  
              &lt;EditText
                  android:id="@+id/editLengthLabel"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:layout_below="@id/spinnerSpeciesType"
                  android:ems="5"
                  android:hint="@string/hint_length"
                  android:inputType="numberDecimal" /&gt;
  
              &lt;EditText
                  android:id="@+id/editWeightLabel"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentEnd="true"
                  android:layout_alignParentRight="true"
                  android:layout_below="@id/spinnerSpeciesType"
                  android:ems="5"
                  android:hint="@string/hint_weight"
                  android:inputType="numberDecimal" /&gt;
  
              &lt;EditText
                  android:id="@+id/editLengthLabel2"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentStart="true"
                  android:layout_below="@id/editLengthLabel"
                  android:ems="5"
                  android:hint="@string/hint_length"
                  android:inputType="numberDecimal" /&gt;
  
              &lt;EditText
                  android:id="@+id/editWeightLabel2"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentEnd="true"
                  android:layout_alignParentRight="true"
                  android:layout_below="@id/editWeightLabel"
                  android:ems="5"
                  android:hint="@string/hint_weight"
                  android:inputType="numberDecimal" /&gt;
  
          &lt;/RelativeLayout&gt;
  
      &lt;/ScrollView&gt;
  
  &lt;/com.ahappydevelopment.android.fishtales.views.LogEditView&gt;
  </code></pre>
  
  <p>As you can see, my layout does include a <code>ScrollView</code>. I have even defined the <code>android:theme="@style/DialogTheme"</code> in the layout. I have tried setting <code>android:fillViewport="true"</code> on the ScrollView, as I saw in another StackOverflow posting.</p>
  
  <p>On the Java side of things, I have an override for the <code>onCreateDialog</code> method defined as such:</p>
  
  <pre><code>@NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      Dialog dialog = new Dialog(getActivity(), R.style.DialogTheme);
      //set to adjust screen height automatically, when soft keyboard appears on screen
      dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
      return dialog;
  }
  </code></pre>
  
  <p>The <code>Fragment</code> that initiates the <code>DialogFragment</code> has a method that looks like this:</p>
  
  <pre><code>public void addLogButtonOnClickEvent() {
      LogEditFragment addLog = LogEditFragment.get(0l);
      if(mIsLargeLayout) {
          // The device is using a large layout, so show the fragment as a dialog
          addLog.show(getFragmentManager(), "AddLog");
      } else {
          // The device is smaller, so show the fragment fullscreen
          FragmentTransaction transaction = getFragmentManager().beginTransaction();
          // For a little polish, specify a transition animation
          transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
          // To make it fullscreen, use the 'content' root view as the container
          // for the fragment, which is always the root view for the activity
          transaction.add(android.R.id.content, addLog).addToBackStack(null).commit();
      }
  }
  </code></pre>
  
  <p>As I said, this is working fine for the KitKat emulator. This is NOT working for the Lollipop emulator.  You can see that I am trying very hard to get the <code>DialogFragment</code> to do adjust resize. :-) Does anyone see what I am missing or doing wrong? Also, if there is code that I have neglected to include that would help to find a solution, the please let me know, and I will post that as well. Thank you for any insight you can provide.</p>