search

Home  >  Q&A  >  body text

android-ui - 使用 Android shape标签中的line能不能指定画出的线的起始点和结束点

我现在想用shape标签画一个叉号,但是指定android:shape="line"之后没有发现那个属性是指定画的线的起始和结束位置的。
我用下面的代码画出来的线只能是水平的:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    <stroke android:color="@android:color/holo_blue_light"
        android:width="3dip" />
</shape>

这个问题怎么整啊?还是shape无法指定这种效果的?

怪我咯怪我咯2772 days ago634

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-17 16:25:22

    Shape cannot specify position attributes. Width, height, length, coordinates, etc. belong to the properties of the View control. Shape depends on the existence of the View control and cannot exist and be displayed independently

    reply
    0
  • 阿神

    阿神2017-04-17 16:25:22

     <rotate
                android:fromDegrees="45"
                android:toDegrees="135"
                >
                <shape android:shape="rectangle">
                    <size
                        android:width="200dp"
                        android:height="1dp"
                        />
    
                    <solid android:color="@color/black"/>
                </shape>
            </rotate>

    I don’t know what is the length and starting position of the line, but the angle is still ok

    reply
    0
  • Cancelreply