How to customize the width and height when show an Activity as a Dialog

前端 未结 5 1127
时光取名叫无心
时光取名叫无心 2020-12-08 19:41

If I have defined a Activity:

public class DialogActivity extends Activity{

    @Override
    public void onCreate(Bundle savedInstanceState) {
        supe         


        
5条回答
  •  自闭症患者
    2020-12-08 20:28

    I finally figured out one way to customize the size of my DialogActivity.

    That's inside the onCreate() method of DialogActivity, add the following code:

    WindowManager.LayoutParams params = getWindow().getAttributes();  
    params.x = -20;  
    params.height = 100;  
    params.width = 550;  
    params.y = -10;  
    
    this.getWindow().setAttributes(params); 
    

提交回复
热议问题