在Android DialogFragments中隐藏应用程序标题和图标/徽标

时间:2014-01-02 06:24:50

标签: android android-fragments

当我展示Android DialogFragment子类时,我无法隐藏标题栏和徽标。有谁知道怎么做?

2 个答案:

答案 0 :(得分:1)

隐藏标题,徽标/图标:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}

为布局提供新的宽度和高度:

@Override
public void onStart() {
    int dialogWidth = 800;
    int dialogHeight = LayoutParams.WRAP_CONTENT;
    Window window = getDialog().getWindow();
    window.setLayout(dialogWidth, dialogHeight);
    window.setGravity(Gravity.CENTER);
    super.onStart();
}

答案 1 :(得分:0)

只需在HelpDialog.onCreateView(...)

中添加此行代码即可
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);

这样你就明确要求获得一个没有标题的窗口:)

编辑:

LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, 
                                   LayoutParams.WRAP_CONTENT);
myview.setLayoutParams(lp);

layoutparams(widht,height)。得到了吗?