如何编辑自定义对话框背景?



在此处输入图像描述

我是安卓编程的新手,我还在学习 我想去除这个变形的部分,但我尝试了各种方法,但没有成功。你可以帮我吗?

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/buttonshape"
android:padding="10dp">
<Button
android:id="@+id/button"
android:layout_width="42dp"
android:layout_height="30dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="5dp"
android:background="@drawable/click"
android:text="تم"
android:textColor="#fff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/radioGroup"
app:layout_constraintVertical_bias="0.27999997" />

简而言之,要从对话框中删除空白区域,您必须使对话框背景透明,以便它可以只显示使用的区域。 尝试

dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); 

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

最新更新