Android 对话框弧形边缘

Android Dialog curved edges

我在 android 中实现了自定义对话框。自定义视图包含弯曲的边缘但不包含对话框本身。我希望此对话框获得弯曲边缘的形状。怎么做到的?

如您所见,弯曲的边缘实际上并不是曲线。 任何帮助或想法将不胜感激。

解决方案

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

谢谢大家。 编码愉快。

我想有两个可能的原因使您的自定义视图变成这样:

  1. 您忘记先将对话框的背景设置为透明;
  2. 自定义背景图的边角部分未设置透明(可以设置透明后保存为png格式)

A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.

您需要在 Android 中创建自定义对话框。

  1. 创建自定义对话框布局(XML 文件)。
  2. 将布局附加到对话框。

请查看下面的演示链接

  1. Android Custom Dialog Tutorial

  2. How to create custom Dialog Box in android ?