Android: how to create a transparent dialog-themed activity

前端 未结 6 1307
清歌不尽
清歌不尽 2020-12-03 05:04

My original goal here was a modal dialog, but you know, Android didn\'t support this type of dialog. Alternatively, building a dialog-themed activity would possibly work.

6条回答
  •  无人及你
    2020-12-03 05:59

    Just one thing to add to all the answers here. To achieve a full dialog like behaviour, you can reposition the dialog by changing the window layout params:

    WindowManager.LayoutParams params = getWindow().getAttributes(); 
    params.x = ...;
    params.y = ...;
    params.width = ...;
    params.height = ...;
    
    this.getWindow().setAttributes(params);
    

    We used a similar technique to achieve a floating activity effect in the Tooleap SDK:

    floating calculator

提交回复
热议问题