如何使行程3双方在机器人的形状? [英] how to make stroke for 3 sides for a shape in android?

查看:173
本文介绍了如何使行程3双方在机器人的形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是中风,使彩色边框,以在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>

这篇关于如何使行程3双方在机器人的形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆