没有背景的直边矩形的android圆角矩形 [英] android rounded rectangle without background straight-edge rectangle

查看:262
本文介绍了没有背景的直边矩形的android圆角矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让显示为一个圆角矩形的对话框。我通过指定以下形状XML作为背景的​​对话框layout.xml

I'm trying to make a dialog that appears as a rounded rectangle. I'm doing this by specifying the following shape xml as the background for the dialog layout.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid    android:color="#FFFFFF"/>
    <corners  android:radius="40dp"/>
    <padding  android:left="10dp"
          android:right="10dp"
          android:top="10dp"
          android:bottom="10dp"/>
</shape>

在出现的对话框中有一个黑色的90度矩形内圆角。我想知道我怎么能摆脱九十度矩形剩下的,并显示不过是圆角矩形。

The resulting dialog has rounded corners inside a black 90 degree rectangle. I want to know how I can get rid of the ninety degree rectangle that remains and show nothing but the rounded rectangle.

这似乎是长方形的模板后,我的曲线边角留下的:

It seems like the rectangle template stays behind after I curve the corners:

下面有一个链接到该对话框的图片我的code的生产: HTTP: //img577.imageshack.us/img577/8292/photoon20110912at2032.jpg

Here's a link to a picture of the dialog my code's producing: http://img577.imageshack.us/img577/8292/photoon20110912at2032.jpg

推荐答案

写您的构造函数:

公共CustomDialog(上下文的背景下,诠释主题){         超(背景下,主题);         getWindow()setBackgroundDrawable(新ColorDrawable(android.graphics.Color.TRANSPARENT))。     }

public CustomDialog(Context context, int theme) { super(context, theme); getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); }

这篇关于没有背景的直边矩形的android圆角矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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