Android - 创建一个使用现有操作栏的对话框

时间:2015-12-07 16:02:15

标签: android dialog

我正在寻找一个对话框,允许我从父活动中连接现有的操作栏。我有一个菜单按钮,所以如果对话框打开,我仍然可以打开菜单。

以下是我创建窗口的方法:

@Override
public void onCreate(Bundle savedInstanceState) {

    this.requestWindowFeature(Window.FEATURE_ACTION_BAR);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);

    WindowManager.LayoutParams params = this.getWindow().getAttributes();
    params.alpha = 1.0f;
    params.dimAmount = 0.5f;
    this.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    // This sets the window size, while working around the IllegalStateException thrown by ActionBarView
    this.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
    this.getWindow().getAttributes().gravity = Gravity.BOTTOM;

    super.onCreate(savedInstanceState);

    init(CompareViewActivity.this);
    setContentView(currentView);


}

0 个答案:

没有答案