我想添加一个线性布局,具有透明的背景和白色的边框。问题是:就我在谷歌上搜索过的而言,我只能做到两者中的一个。
下面是我所做的:
......
当包含边框时,我得到了不透明的背景。
我希望最终结果是这样的:
完全坚持下来了。只是想找到一种方法来实现它。任何建议都会很有帮助。
发布于 2013-01-26 17:53:51
你的绘图布局的背景:
如果需要,可以更改拐角形状的半径。但是笔划将创建一个边框,而实体部分是我们要使其透明的背景。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="2dp"
android:topRightRadius="0dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
<solid android:color="@android:color/transparent"/>
</shape>
和我的测试layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/ll2"
android:layout_height="50dp"
android:layout_width="50dp"
android:background="@drawable/my_transparent_linear_layout"></LinearLayout>
</LinearLayout>
它可以工作,下面是证明:
发布于 2013-01-26 17:43:56
可绘制为背景的Xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="30dp" />
<stroke android:width="5dp" android:color="#ffffffff"/>
<solid android:color="#66000000"/>
</shape>
调整半径,宽度和深色透明度( #ff和#66部分)随你喜欢。
发布于 2013-01-26 17:44:37
为此,您可以使用两个布局aligned
,一个在另一个的顶部,然后为top view
设置背景transparent
,并将白色边框设置为bottom view
的背景。你可以在relative layouts
中做这件事。
https://stackoverflow.com/questions/14535644
复制相似问题