FragmentDialog常见问题

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    initView();
    View contentView = inflater.inflate(R.layout.fragment_auto_raise, container, false);
    unbinder = ButterKnife.bind(this, contentView);
    return contentView;
}
private void initView() {
    Window window = getDialog().getWindow();
    /** 去4.4,5.1空Title */
    window.requestFeature(Window.FEATURE_NO_TITLE);
    //设置弹出动画
    WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();
    params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    params.windowAnimations = R.style.Animation_Bottom_Rising;
    //设置宽高自适应,去掉左右两侧边距
    window.getDecorView().setPadding(0, 0, 0, 0);
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = (int) (DisplayUtils.getInstance(getActivity()).getScreenHeight() * 0.9);
    window.setAttributes(params);
    //点击外部可以取消
    getDialog().setCanceledOnTouchOutside(true);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}

动画文件




    

    




    

    

 

你可能感兴趣的:(FragmentDialog常见问题)