没有标题的DialogFragment - ScrollView不会滚动

Axa*_*dax 6 android scrollview

我有一个滚动的ScrollView内部,DialogFragment直到我意识到对话框不应该有标题,所以我打电话给(in onCreateView)

requestFeature(Window.FEATURE_NO_TITLE);
Run Code Online (Sandbox Code Playgroud)

然后ScrollView不再允许滚动,底部视图被挤压在一起.该ScrollView包含垂直LinearLayout与应溢出屏幕的一些看法.

dea*_*ish 4

您应该通过继承当前的 android 对话框并添加windowSoftInputMode选项来为片段对话框设置自定义主题

<style name="DialogFragmentStyle" parent="@android:style/Theme.Dialog">
        <item name="android:windowSoftInputMode">stateHidden|adjustResize</item>
</style>
Run Code Online (Sandbox Code Playgroud)

创建构造函数时在片段对话框中使用您的主题

对话框 对话框 = 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

}
Run Code Online (Sandbox Code Playgroud)