前言:
网上说了一堆好处,我只说自己深有体会的两点吧
1.屏幕横竖屏切换的时候,弹框可以保存状态
2.可以在popwindow中使用
使用步骤
1.创建继承DialogFragment的dialogFragment类
public class CardDialogFragment extends DialogFragment {
public static CardDialogFragment newInstance() {
Bundle args = new Bundle();
CardDialogFragment fragment = new CardDialogFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.gravity = Gravity.CENTER;
window.setAttributes(params);
window.setBackgroundDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.circle5_white));
window.setWindowAnimations(R.style.BottomDialog