}
@Override
public void onStart() {
/*Dialog dialog = getDialog();
if (dialog != null) {
Window window = Window();
if (window != null) {
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
// 1 设置全屏
/
/ window.setLayout(width, height);
// 2. 设置指定⼤⼩
// window.setLayout(750, 600);
// 3. 设置占⽤屏幕宽度⼀定⽐例
DisplayMetrics dm = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
}
}*/
// 设置dialog⼤⼩和位置
Window win = getDialog().getWindow();
WindowManager.LayoutParams params = Attributes();
//  params.y = DisplayUtils.dip2px(getContext(), 100);// 具体头部距离
params.width = (ViewGroup.LayoutParams.MATCH_PARENT); // ⼤⼩
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
win.setAttributes(params);
}
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
CreateDialog(savedInstanceState);
/
* AlertDialog dialog = new AlertDialog.Builder(getActivity())
.setTitle("神灯")
.setMessage("来选择你要实现的⼀个愿望把")
.setPositiveButton("车⼦", new DialogInterface.OnClickListener() {
alertdialog使用方法@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getActivity(), "车⼦", Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
})
.setNegativeButton("房⼦", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getActivity(), "房⼦", Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
}).create();
return dialog;*/
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {    // ⾃定义布局:
//1.必须设置dialog的window背景为透明颜⾊,不然圆⾓⽆效或者是系统默认的颜⾊
// getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
View view = inflater.from(getActivity()).inflate(R.layout.fragment_dialog, container, false);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
TextView mTvTitle = view.findViewById(R.id.tv_title);
TextView mTvContent = view.findViewById(R.id.tv_content);

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。