title: Keyboard won't show for EditText inside a ViewPager2 in a DialogFragment
body: <p>I have a layout - let's call it layout A - with some <code>EditText</code>s, which I inflate inside a <code>DialogFragment</code> and all goes well with them. I have another <code>DialogFragment</code> whose layout - let's call it layout B - has a <code>ViewPager2</code> in it, and I use it with a <code>FragmentStateAdapter</code> which hosts fragments where I reuse layout A for each of them.</p>
  <p>Now my problem is that when I tap on the <code>EditText</code>s inside the <code>ViewPager2</code>, they seem to be getting focus (my grasp of that subject isn't perfect), the cursor starts showing and I can manipulate the text with it (&quot;select&quot;, &quot;select all&quot;, &quot;cut&quot;, etc.), but the soft keyboard won't open up.
  In the dialog without the viewPager, those same <code>EditText</code>s work flawlessly and the keyboard opens up.</p>
  <p>In the Android Manifest I have <code>android:windowSoftInputMode=&quot;adjustPan&quot;
  </code> (I use a single activity in my app).</p>
  <p>What could be the problem?</p>
  <p>My code:</p>
  <p>Layout A:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
  
      &lt;TextView
          android:id=&quot;@+id/title_text_view&quot;
          android:layout_width=&quot;60dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginStart=&quot;@dimen/double_margin&quot;
          android:layout_marginLeft=&quot;@dimen/double_margin&quot;
          android:text=&quot;@string/title_colon&quot;
          android:textStyle=&quot;bold&quot;
          app:layout_constraintBottom_toBottomOf=&quot;@id/title_edit_text&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;@id/title_edit_text&quot; /&gt;
  
      &lt;EditText
          android:id=&quot;@+id/title_edit_text&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginEnd=&quot;@dimen/double_margin&quot;
          android:layout_marginRight=&quot;@dimen/double_margin&quot;
          android:autofillHints=&quot;false&quot;
          android:ellipsize=&quot;end&quot;
          android:hint=&quot;@string/enter_track_title&quot;
          android:inputType=&quot;textCapWords|textMultiLine&quot;
          android:maxLines=&quot;2&quot;
          android:textSize=&quot;14sp&quot;
          app:layout_constraintBottom_toTopOf=&quot;@id/position_edit_text&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toEndOf=&quot;@id/title_text_view&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/position_text_view&quot;
          android:layout_width=&quot;60dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginStart=&quot;@dimen/double_margin&quot;
          android:layout_marginLeft=&quot;@dimen/double_margin&quot;
          android:text=&quot;@string/number_dot&quot;
          android:textStyle=&quot;bold&quot;
          app:layout_constraintBottom_toBottomOf=&quot;@id/position_edit_text&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;@id/position_edit_text&quot; /&gt;
  
      &lt;EditText
          android:id=&quot;@+id/position_edit_text&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;@dimen/margin&quot;
          android:layout_marginEnd=&quot;@dimen/double_margin&quot;
          android:layout_marginRight=&quot;@dimen/double_margin&quot;
          android:layout_marginBottom=&quot;@dimen/margin&quot;
          android:autofillHints=&quot;false&quot;
          android:ellipsize=&quot;end&quot;
          android:hint=&quot;@string/enter_track_position&quot;
          android:inputType=&quot;text&quot;
          android:maxLength=&quot;6&quot;
          android:maxLines=&quot;1&quot;
          android:textSize=&quot;14sp&quot;
          app:layout_constraintBottom_toTopOf=&quot;@id/duration_text_view&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toEndOf=&quot;@id/position_text_view&quot;
          app:layout_constraintTop_toBottomOf=&quot;@id/title_edit_text&quot;
          tools:ignore=&quot;TextFields&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/duration_text_view&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;@string/duration_colon&quot;
          android:textStyle=&quot;bold&quot;
          android:layout_marginBottom=&quot;@dimen/double_margin&quot;
          app:layout_constraintBottom_toTopOf=&quot;@id/colon_text_view&quot;
          app:layout_constraintEnd_toEndOf=&quot;@id/seconds_picker&quot;
          app:layout_constraintStart_toStartOf=&quot;@id/minutes_picker&quot;
          app:layout_constraintTop_toBottomOf=&quot;@id/position_edit_text&quot; /&gt;
  
      &lt;NumberPicker
          android:id=&quot;@+id/minutes_picker&quot;
          android:layout_width=&quot;80dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginStart=&quot;@dimen/double_margin&quot;
          android:layout_marginLeft=&quot;@dimen/double_margin&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toStartOf=&quot;@id/colon_text_view&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@id/duration_text_view&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/colon_text_view&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_margin=&quot;@dimen/margin&quot;
          android:text=&quot;@string/colon&quot;
          android:textSize=&quot;42sp&quot;
          app:layout_constraintBottom_toBottomOf=&quot;@id/minutes_picker&quot;
          app:layout_constraintEnd_toStartOf=&quot;@id/seconds_picker&quot;
          app:layout_constraintStart_toEndOf=&quot;@id/minutes_picker&quot;
          app:layout_constraintTop_toTopOf=&quot;@id/minutes_picker&quot;
          app:layout_constraintVertical_bias=&quot;0.42000002&quot; /&gt;
  
      &lt;NumberPicker
          android:id=&quot;@+id/seconds_picker&quot;
          android:layout_width=&quot;80dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginEnd=&quot;@dimen/double_margin&quot;
          android:layout_marginRight=&quot;@dimen/double_margin&quot;
          app:layout_constraintBottom_toBottomOf=&quot;@id/minutes_picker&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toEndOf=&quot;@id/colon_text_view&quot;
          app:layout_constraintTop_toTopOf=&quot;@id/minutes_picker&quot; /&gt;
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>Layout B:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
      &lt;View
          android:id=&quot;@+id/edit_track_divider_1&quot;
          style=&quot;@style/divider&quot;
          android:layout_marginTop=&quot;@dimen/double_margin&quot;
          app:layout_constraintBottom_toTopOf=&quot;@id/left_arrow&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
      &lt;ImageButton
          android:id=&quot;@+id/left_arrow&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginStart=&quot;@dimen/quadruple_margin&quot;
          android:layout_marginLeft=&quot;@dimen/quadruple_margin&quot;
          android:layout_marginTop=&quot;@dimen/double_margin&quot;
          android:background=&quot;@android:color/transparent&quot;
          android:contentDescription=&quot;@string/left_arrow_image&quot;
          android:scaleX=&quot;1.5&quot;
          android:scaleY=&quot;1.5&quot;
          app:layout_constraintBottom_toTopOf=&quot;@id/edit_tracks_pager&quot;
          app:layout_constraintEnd_toStartOf=&quot;@id/right_arrow&quot;
          app:layout_constraintHorizontal_chainStyle=&quot;spread_inside&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@id/edit_track_divider_1&quot;
          app:srcCompat=&quot;@drawable/ic_action_left&quot; /&gt;
  
      &lt;TextView
          android:id=&quot;@+id/position_header&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:gravity=&quot;center&quot;
          app:layout_constraintBottom_toBottomOf=&quot;@id/left_arrow&quot;
          app:layout_constraintEnd_toStartOf=&quot;@id/right_arrow&quot;
          app:layout_constraintStart_toEndOf=&quot;@id/left_arrow&quot;
          app:layout_constraintTop_toTopOf=&quot;@id/left_arrow&quot; /&gt;
  
      &lt;ImageButton
          android:id=&quot;@+id/right_arrow&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginEnd=&quot;@dimen/quadruple_margin&quot;
          android:layout_marginRight=&quot;@dimen/quadruple_margin&quot;
          android:background=&quot;@android:color/transparent&quot;
          android:contentDescription=&quot;@string/right_arrow_image&quot;
          android:scaleX=&quot;1.5&quot;
          android:scaleY=&quot;1.5&quot;
          app:layout_constraintBottom_toBottomOf=&quot;@+id/left_arrow&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toEndOf=&quot;@id/left_arrow&quot;
          app:layout_constraintTop_toTopOf=&quot;@+id/left_arrow&quot;
          app:srcCompat=&quot;@drawable/ic_action_right&quot; /&gt;
  
  
      &lt;androidx.viewpager2.widget.ViewPager2
          android:id=&quot;@+id/edit_tracks_pager&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          app:layout_constraintBottom_toTopOf=&quot;@id/edit_track_divider_2&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@id/left_arrow&quot; /&gt;
  
      &lt;View
          android:id=&quot;@+id/edit_track_divider_2&quot;
          style=&quot;@style/divider&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toBottomOf=&quot;@id/edit_tracks_pager&quot; /&gt;
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>