如何只从元件的一侧删除边框? [英] How to remove border only from one side of the element?
问题描述
我有:
<stroke android:width="1px" android:color="#A6ACB1"/>
我想从元件的底部(例如)删除此边框。可能吗? (Eclipse的只是建议我:颜色,宽度,dashWidth和dashGap)。
I'd like to remove this border from the bottom (for example) of the element. Is it possible? (Eclipse suggests me only: color, width, dashWidth and dashGap).
推荐答案
据我所知,还没有这样做的一个简单的方法。但如果使用图层列表与具有边框上,然后一个不与从您想要的边框等于边框的宽度,你的所有边抵消项目实现这一目标。
As far as I understand it, there isn't an easy way of doing it. but if you use layer-list with an item that has the border and then one that doesn't with an offset from all the sides for which you want a border equal to the border width, you'd achieve that.
请允许我向XML为你重新presenting无边框底部。
Let me make the xml for you representing the borderless bottom..
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Border -->
<item>
<shape>
<solid android:color="#f000"></solid>
</shape>
</item>
<!-- Body -->
<item android:left="2dip"
android:top="2dp"
android:right="2dp">
<shape>
<solid android:color="#ffafafaf"></solid>
</shape>
</item>
</layer-list>
正如你所看到的,我说的是第二项底部,除了各方面(因此底部的无边框结果)被镶嵌第一个由两个DP的,你去那里:
As you can see, I'm telling the second item to be inset of the first one by two dp's on all sides except bottom (hence the no-border result on the bottom), there you go:
所以基本上这是不是每本身的边界,它是从波纹管的形状(但如果你需要虚线或点,或任何你可以添加一个边框)所覆盖的第二个项目将是按钮的身体。位于同一抽拉:)
So essentially this isn't a border per-se, it's the shape from bellow (although you could add a border if you need dashed or dotted or whatever) being covered by a second item with would be the body of the button. All in the same drawable :)
这可以应用到你要删除的任何边界,通过改变该项目是插图,例如,如果我改变其值右键
在车身项目以底
,缺少的边框会,因为它是正确的是一个没有插入
This can be applied to any border you want to remove, by changing the values that the item is inset, for example, if I change the right
in the Body item to bottom
, the missing border would the right one since it's the one without the inset
这篇关于如何只从元件的一侧删除边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!