Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DialogFragment with no title - ScrollView does not scroll

I have a ScrollView inside of DialogFragment that scrolled fine until I realized that the dialog shouldn't have a title, so I called (in onCreateView)

requestFeature(Window.FEATURE_NO_TITLE);

Then the ScrollView doesn't allow scrolling anymore and the bottom views are squished together. The ScrollView contains a vertical LinearLayout with some views that should overflow the screen.

like image 332
Axarydax Avatar asked Nov 03 '13 17:11

Axarydax


People also ask

How do I make a scrollable BottomSheet?

Flexible and scrollable bottom sheet. All you have to do is call showFlexibleBottomSheet() and you'll get a popup that looks like a modal bottom sheet and can be resized by dragging it up and down and scrolled when expanded. There are 2 types of BottomSheets: BottomSheet.

How do I know if DialogFragment is showing?

Showing the DialogFragment Instead, use the show() method to display your dialog. You can pass a reference to a FragmentManager and a String to use as a FragmentTransaction tag.

How to implement scroll view in android?

In Android, a ScrollView is a view group that is used to make vertically scrollable views. A scroll view contains a single direct child only. In order to place multiple views in the scroll view, one needs to make a view group(like LinearLayout) as a direct child and then we can define many views inside it.


1 Answers

You should set custom theme for your fragment dialog by inheriting current android dialog and adding windowSoftInputMode option:

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

Use your theme in your fragment dialog while creating constructor

Dialog dialog = new Dialog(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

}
like image 102
deadfish Avatar answered Sep 28 '22 14:09

deadfish