[英]android rounded rectangle drawable question
I used the source code below to create the above background image.我使用下面的源代码来创建上面的背景图像。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:height="40dp"
android:gravity="top"
>
<shape>
<solid android:color="@color/white100" />
<stroke
android:width="1dp"
android:color="@color/gray_BB"
/>
<corners
android:topLeftRadius="3dp"
android:topRightRadius="3dp"
/>
</shape>
</item>
<item
android:height="40dp"
android:gravity="bottom"
>
<shape>
<solid android:color="@color/gray_F4" />
<stroke
android:width="1dp"
android:color="@color/gray_BB"
/>
<corners
android:bottomLeftRadius="3dp"
android:bottomRightRadius="3dp"
/>
</shape>
</item>
</layer-list>
There was a problem that the two gray areas of the center view overlap and appear in 2dp.有一个问题,中心视图的两个灰色区域重叠并出现在 2dp 中。
How can I display only 1dp without overlapping the center view gray?如何在不重叠中心视图灰色的情况下仅显示 1dp?
++ ++
This is the image I am trying to achieve这是我想要达到的形象
You need to increase the height of the most front drawable as much as it overlays the one underneath and covers its stroke:您需要增加最前面的 drawable 的高度,使其覆盖下面的一个并覆盖其笔划:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:height="40dp"
android:gravity="top"
...
</item>
<!-- This item overlays the other -->
<item
android:height="41dp"
android:gravity="bottom">
...
</item>
</layer-list>
Note that your view height has to be 80dp
for the drawable to overlap and cover properly.请注意,您的视图高度必须为
80dp
,drawable 才能正确重叠和覆盖。
It is not implementable with layer-list
.它不能用
layer-list
。 Also, if you don't want any overlap, and still want 1dp, which color would that line be?另外,如果您不想要任何重叠,并且仍然想要 1dp,那条线是什么颜色?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.