如何清除自定义对话框的矩形框 [英] how to remove rectangle frame of the custom dialog

查看:107
本文介绍了如何清除自定义对话框的矩形框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定制一个对话框:

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),然后系统框架似乎有删除,但只有四角不去除,我们也看到黑暗的四角,因为我使用圆角矩形图像.so我的问题如何删除所有的框架,使我的对话框看起来很好

my dialog is vrry well,but custom_diolog_bg is a rounded rectangle image,and when i show my dialog ,it show a system Frame behide my custom,so i used this.getwindow.setBackgroundDrawable(null),then the system Frame seems have remove but only the Four Corners not remove,we also see dark Four Corners,because i used the rounded rectangle image.so my question how to remove all the Frame so that my dialog seem Very well

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

the pic is http://i.stack.imgur.com/EG7oz.jpg ,so you can see there is dark frame in the last,how to remove it? thank you

推荐答案

为我工作的解决方案

<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);

这篇关于如何清除自定义对话框的矩形框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆