gpt4 book ai didi

android - 如何删除自定义对话框的矩形框

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:48:26 25 4
gpt4 key购买 nike

我自定义一个对话框:

public class CustomizeDialog extends Dialog implements OnClickListener {
Button close;
TextView tv;
public CustomizeDialog(Context context,String Stringcontent) {
super(context);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.custom_diolog_main);
tv=(TextView) findViewById(R.id.content);
tv.setText(Stringcontent);
close = (Button) findViewById(R.id.close);
close.setOnClickListener(this);
}

@Override
public void onClick(View v) {
if (v == close)
dismiss();
}

}

xml是

   <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="100dip"
android:orientation="vertical"
android:background="@drawable/custom_diolog_bg"
android:layout_width="250dip">
<TextView android:layout_height="wrap_content"
android:textColor="#000"
android:textStyle="bold"
android:textSize="18sp"
android:id="@+id/content"
android:layout_marginLeft="15dip"
android:layout_marginTop="5dip"
android:layout_alignParentTop="true"
android:layout_width="250dip"
android:text=" Custom Dialog "/>


<Button android:layout_width="70dip"
android:layout_marginLeft="80dip"
android:background="@drawable/custom_dialog_button_bg"
android:layout_alignParentBottom="true"
android:layout_height="40dip" android:text="关闭"
android:id="@+id/close"></Button>
</RelativeLayout>

我的对话框很好,但是 custom_diolog_bg 是一个圆角矩形图像,当我显示我的对话框时,它在我的自定义后面显示了一个系统框架,所以我使用了 this.getwindow.setBackgroundDrawable(null),然后系统框架似乎已经删除但只有四个角没有删除,我们还看到了黑色的四个角,因为我使用了圆角矩形图像。所以我的问题是如何删除所有框架,以便我的对话框看起来很好

图片是http://i.stack.imgur.com/EG7oz.jpg ,所以你可以看到最后有黑框,如何去除它?谢谢

最佳答案

对我有用的解决方案

<style name="DialogTheme" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
</style>

Dialog dialog = new Dialog(this, R.style.DialogTheme);

关于android - 如何删除自定义对话框的矩形框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7497449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com