我使用的是中风,使彩色边框,以在Android的XML布局的形状。
I am using a stroke to make a colored border to a shape in xml layout in android .
我可以使行程只有3边(左,上,下),右NO?
Can I make the stroke for only 3 edges ( left,top,bottom) the right NO ?
推荐答案
您可以通过使用layerlist和填充搞乱实现这一目标。你需要3个要素:
You can achieve this by using a layerlist and messing with the padding. You'll need 3 elements:
1:border.xml形状,这仅仅是一个坚实的形状边框的颜色:border.xml
1: A border.xml shape, which is just a solid shape in the color of your border: border.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ff0000"/>
</shape>
2:内在的形状,在这里你想要的边框周围出现形状:inner.xml
2: The 'inner' shape, the shape where you want the border to appear around: inner.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00ff00"/>
</shape>
3:图层列表,它会把这2海誓山盟的顶部。您可以通过设置填充的内部形状创建边框:layerlist.xml
3: A layer list, which will put these 2 on top of eachother. You create the border by setting the padding on the inner shape: layerlist.xml
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/border"/>
<item android:drawable="@drawable/inner"
android:top="3dp" android:right="0dp" android:bottom="3dp"
android:left="3dp" />
</layer-list>
相关推荐
最新文章