gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:05:01 25 4
gpt4 key购买 nike

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com