机器人的形状,底部行程 [英] android shape with bottom stroke
本文介绍了机器人的形状,底部行程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个机器人形状,使得只有底部具有中风(虚线)。当我尝试以下方法,行程平分的形状通过中心的权利。有谁知道如何得到它的权利?行程需要是底线/边框。我现在用的形状作为背景,以一个TextView。拜托,别提了,为什么我需要它。
< XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目>
<形机器人:形状=矩形>
[固体机器人:颜色=#1bd4f6/>
< /形状>
< /项目>
<项目>
<形机器人:形状=行>
<填充安卓底=1DP/>
<中风
机器人:dashGap =10px的
机器人:dashWidth =10px的
机器人:宽=1DP
机器人:颜色=#ababb2/>
< /形状>
< /项目>
< /层列表>
解决方案
这是怎样的一个黑客,但我想这大概是做到这一点的最好办法。虚线将始终在底部,无论高度。
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目>
<形机器人:形状=矩形>
[固体机器人:颜色=#1bd4f6/>
< /形状>
< /项目>
<项目的android:顶部= - 2DP机器人:右= - 2DP机器人:左边= - 2DP>
<形状>
[固体机器人:颜色=@机器人:彩色/透明/>
<中风
机器人:dashGap =10px的
机器人:dashWidth =10px的
机器人:宽=1DP
机器人:颜色=#ababb2/>
< /形状>
< /项目>
< /层列表>
I need to create an android shape so that only the bottom has stroke (a dashed line). When I try the following, the stroke bisects the shape right through the center. Does anyone know how to get it right? the stroke needs to be the bottom line/border. I am using the shape as a background to a TextView. Please, never mind why I need it.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<solid android:color="#1bd4f6" />
</shape>
</item>
<item>
<shape android:shape="line" >
<padding android:bottom="1dp" />
<stroke
android:dashGap="10px"
android:dashWidth="10px"
android:width="1dp"
android:color="#ababb2" />
</shape>
</item>
</layer-list>
解决方案
It's kind of a hack, but I think this is probably the best way to do it. The dashed line will always be on the bottom, regardless of the height.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<solid android:color="#1bd4f6" />
</shape>
</item>
<item android:top="-2dp" android:right="-2dp" android:left="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:dashGap="10px"
android:dashWidth="10px"
android:width="1dp"
android:color="#ababb2" />
</shape>
</item>
</layer-list>
这篇关于机器人的形状,底部行程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文