使用XML绘制垂直线 [英] Vertical line using XML drawable

查看:318
本文介绍了使用XML绘制垂直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何定义一个垂直线(1DP厚)用作一个可绘制。

I'm trying to figure out how to define a vertical line (1dp thick) to be used as a drawable.

要创建一条水平之一,它是pretty的简单:

To make a horizontal one, it's pretty straightforward:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
    <stroke android:width="1dp" android:color="#0000FF"/>
    <size android:height="50dp" />     
</shape>

现在的问题是,如何让这条线垂直?

The question is, how to make this line vertical?

是的,有解决方法,比如画一个矩形1px的厚,但复杂的绘制XML,如果它由多个&LT;项目&GT; 元素

Yes, there are workarounds, such as drawing a rectangle shape 1px thick, but that complicates the drawable XML, if it consists of multiple <item> elements.

任何人有任何机会,与此?

Anyone had any chance with this?

更新

案例仍然没有解决。然而, 对于任何一个Android的文件讨伐 - 你可能会发现这个有用: 缺少的Andr​​oid XML手册

Case is still unsolved. However, For anyone on a Android documentation crusade - you might find this useful: Missing Android XML Manual

更新

我发现没有比我标记为正确的以外其他的方式。它的伎俩,虽然感觉有点重,因此,如果你碰巧知道答案别忘了分享;)

I found no other way other than the one that I marked as correct. It does the trick though feels a bit "heavy", thus if you happen to know the answer don't forget to share ;)

推荐答案

,你可以尝试查看

<View
    android:layout_width="1dp"
    android:layout_height="fill_parent"
    android:background="#FF0000FF" />

我只用这对水平线条,但我认为这是可行的垂直线为好。

I have only used this for horizontal lines, but I would think it would work for vertical lines as well.

使用:

<View
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="#FF0000FF" />

为一条水平线。

for a horizontal line.

这篇关于使用XML绘制垂直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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