1. 程式人生 > >Android 橫豎屏切換時 Custom Dialog 佈局自適應

Android 橫豎屏切換時 Custom Dialog 佈局自適應

    @Override
    public void onContentChanged() {
        super.onContentChanged();
        Display display = mActivity.getWindowManager
        WindowManager.LayoutParams params = this.getWindow().getAttributes();
        params.width = display.getWidth();
        this.getWindow().setAttributes(params);
        this.getWindow().setGravity(Gravity.BOTTOM);
    }