布局小记

Service中创建Dialog 

    public void createWindow(){
        Dialog dialog = new Dialog(getApplicationContext());
        Window window = dialog.getWindow();
        //service中添加window使用该类型,
        //并需要声明权限:
        //
        //
        window.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
        window.setGravity(Gravity.LEFT|Gravity.TOP);
        //设置Dialog背景
        window.setBackgroundDrawableResource(R.color.white);

        WindowManager.LayoutParams layoutParams = window.getAttributes();
        layoutParams.x = 0;
        layoutParams.y = 500;
        //layoutParams.width = 450;
        //layoutParams.height = 300;
        window.setAttributes(layoutParams);

        //去除title
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        window.setContentView(R.layout.activity_main);
        dialog.show();
    }

将布局变为圆角

1.在布局中添加自己的background




    


2.创建background



   
    

 设置Background 为白色,圆角为20px

你可能感兴趣的:(Android应用)