0

(I am working with Xamarin C# but the code is identical to Java)

I created a DialogFragment which inflates a custom layout. The OnCreateView looks like this :

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
  View view = inflater.Inflate(Resource.Layout.dialog_feedback, container);
  int scale = Context.Resources.DisplayMetrics.HeightPixels;
  int height = scale / 2;
  Dialog.Window.SetLayout(ViewGroup.LayoutParams.MatchParent, height);
  Dialog.Window.SetGravity(GravityFlags.Bottom | GravityFlags.CenterHorizontal);
  return view;
}

And the OnCreate looks like this :

public override void OnCreate(Bundle savedInstanceState)
{
  base.OnCreate(savedInstanceState);
  SetStyle(0, Resource.Style.dialog_no_border);
}

Here's the style :

<style name="dialog_no_border" parent="@android:style/Theme.Dialog">
  <item name="android:windowFrame">@null</item>
  <item name="android:windowBackground">@android:color/transparent</item>
  <item name="android:windowIsFloating">false</item>
  <item name="android:windowContentOverlay">@null</item>
  <item name="android:windowTitleStyle">@null</item>
  <item name="android:colorBackgroundCacheHint">@null</item>
  <item name="android:backgroundDimEnabled">true</item>
</style>

The layout that the dialog is inflating contains a ConstraintLayout as the parent and has a AppCompatEditText inside it.

When i open the dialog and click on the EditText, the keyboard overlaps the Edittext. What i'm trying to do is, when the keyboard pops up, it should push up the DialogFragment and show the EditText above itself. How do i achieve that ?

I tried setting android:windowSoftInputMode="adjustNothing", android:windowSoftInputMode="adjustPan", android:windowSoftInputMode="adjustResize" in the activity tag inside the manifest, but with no luck!

So, how do i achieve this ?

Software Dev
  • 5,368
  • 5
  • 22
  • 45
  • [Try this solution, hope it will work for you.](https://stackoverflow.com/a/7435225/11856637) – Shivam Sep 19 '19 at 12:07
  • @Shivam Sorry, it didn't :( – Software Dev Sep 19 '19 at 12:32
  • Does the inflating layout has scrollview ?? or the parent activity has scroll view ?? try adding scrollview to both – Rohit Chauhan Sep 19 '19 at 12:55
  • They parent activity doesn't have a scrollView, it rather has a ViewPager which loads multiple fragments. I am opening the DialogFragment from inside one of the fragments. So where should i add the ScrollView ? @Rj_Innocent_Coder – Software Dev Sep 19 '19 at 12:58
  • you should add scroll view to parent activity but still please add xml of your layout and fragments file, I just solved exect issue today and it get solved by adding scrollview to activity. – Rohit Chauhan Sep 19 '19 at 13:01
  • @Rj_Innocent_Coder, as i mentioned, i can't directly add scrollview to the parent activity. It has a tablayout and a ViewPager to load multiple fragments. However, the parent fragment that opens up the DialogFragment has a ScrollView in it. But the DialogFragment itself doesn't have a ScrollView. So, any ideas on what to do here ? – Software Dev Sep 19 '19 at 13:05
  • please try to add layout files – Rohit Chauhan Sep 20 '19 at 02:55
  • @Rj_Innocent_Coder, already fixed it. It happened due to using the custom style for the dialog. – Software Dev Sep 20 '19 at 06:20
  • Cheers, Keep Coding.. – Rohit Chauhan Sep 20 '19 at 12:25

0 Answers0