DialogFragment without a title - ScrollView does not scroll

I have a ScrollView inside a DialogFragment that scrolls until I understand that the dialog should not have a title, so I called (in onCreateView )

 requestFeature(Window.FEATURE_NO_TITLE); 

Then the ScrollView no longer allows scrolling, and the lower views are twisted together. ScrollView contains a vertical LinearLayout with some views that should overflow the screen.

+6
source share
2 answers

You must set a custom theme for the fragment dialog by inheriting the current Android dialog and adding the windowSoftInputMode option:

 <style name="DialogFragmentStyle" parent="@android:style/Theme.Dialog"> <item name="android:windowSoftInputMode">stateHidden|adjustResize</item> </style> 

Use your theme in the fragment dialog when creating a constructor

Dialogue dialogue = new dialogue (getActivity (), R.style.DialogFragmentStyle );

 public class MyFragmentDialog extends DialogFragment{ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Dialog dialog = new Dialog(getActivity(), R.style.DialogFragmentStyle); //stuff return dialog; } //... other methods } 
+4
source

It will help you

  onCreateDialog(Bundle savedInstanceState) { Dialog dialog = new Dialog(context); dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_layout); dialog.setCanceledOnTouchOutside(false); dialog.show(); } 
0
source

Source: https://habr.com/ru/post/957293/


All Articles