我在 DialogFragment
中有一个 ScrollView
可以很好地滚动,直到我意识到对话框不应该有标题,所以我调用了(在 onCreateView
)
requestFeature(Window.FEATURE_NO_TITLE);
然后 ScrollView
不再允许滚动,底部 View 被挤压在一起。 ScrollView
包含一个垂直的 LinearLayout
,其中一些 View 应该溢出屏幕。
最佳答案
您应该通过继承当前的 android 对话框并添加 windowSoftInputMode 选项为您的 fragment 对话框设置自定义主题:
<style name="DialogFragmentStyle" parent="@android:style/Theme.Dialog">
<item name="android:windowSoftInputMode">stateHidden|adjustResize</item>
</style>
在创建构造函数时在 fragment 对话框中使用主题
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
}
关于android - 没有标题的 DialogFragment - ScrollView 不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19755635/