2014-02-08 72 views
0

我要在Android中创建一个具有圆形形状的提醒对话框。 我遵循这个网站的许多线程。创建shape.xml,并把它绘制资源Android:将圆形形状应用于线性布局

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
<stroke android:width="5dp" android:color="#FF0000" /> 
<corners android:bottomRightRadius="20dp" android:bottomLeftRadius="20dp" 
android:topLeftRadius="20dp" android:topRightRadius="20dp"/> <solid android:color="#FFFF00"/> 

和上面的形状适用于LinearLayout中。 layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:background="@android:color/transparent" > 

<LinearLayout android:layout_width="200dip" 
    android:layout_height="60dip" 
    android:orientation="vertical" 
    android:background="@drawable/shape"> 

</LinearLayout> 

不过,目前仍然有对话框外的矩形边框和背面的颜色。这不是我想要的。 我有很长一段时间的搜索,我不知道如何解决它。 我的目标是让它在对话框布局的角落之外透明。非常感谢!

屏幕截图:http://postimg.org/image/3xbnmquyt/

+0

你能张贴那张图吗? –

+0

就像[http://openclipart.org/people/rg1024/rg1024_set_of_eight_rounded_shapes.svg](this)中间一个的左边。谢谢。 – dsafajw

回答

1

对于要我找到了一个默认的Android Studio形状,这样的:

android:background="@drawable/abc_menu_dropdown_panel_holo_light" 

它应用到你的LinearLayout,这是exatcly你talikng关于什么的,您不需要在drawables中创建其他xml文件。看看它是什么样子看到我的答案在这里: Android View shadow

希望我帮你。

+0

感谢您的评论。对不起,我可能会将您从上面的代码中混淆。我其实想要塑造这样的形状[链接](http://openclipart.org/detail/27891/set-of-eight-round-shapes-by-rg1024-27891)。我最终得到了正确的形状,但角落外面有一种黑色。希望你明白我的意思。谢谢。 – dsafajw

0

删除中风标签,因为它用于创建边框。此外,你不应该使用渐变和坚实,因为他们排除对方。

http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape

+0

是的,我需要创建一个与圆角对齐的边框。但现在在角落外面有一种黑色。我想让它透明。 – dsafajw

+0

好吧,如果您发布布局xml的代码会容易得多,但我认为您应该将您的LinearLayout放在具有相同尺寸但不是圆角的另一个布局中,并将此容器布局的颜色设置为透明或甚至更好地设置与背景相同的颜色。 – mishasrb

+0

我已编辑我的帖子和附加的代码。感谢您的帮助!! – dsafajw