如何在XML数字上添加一行?

时间:2017-07-17 14:06:36

标签: android xml android-layout

你好我有这个用XML创建的三角形,但我想在我的三角形上添加一行。我怎样才能做到这一点 ?

这是我的XML文件:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <rotate
            android:fromDegrees="135"
            android:pivotX="7%"
            android:pivotY="65%" >
            <shape
                android:shape="rectangle" >

                              <solid
                    android:color="@color/green" />
            </shape>
        </rotate>




    </item>

</selector>

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我不知道你是否想在你上面发布的同一个文件中创建一行。

如果要在activity.xml文件中绘制线条,则可以使用ImageView小部件来执行此操作。您需要在colors.xml文件中定义线颜色(您想要的颜色),或者您可以直接在ImageView小部件中硬编码RBG颜色。

<ImageView
android:id="@+id/line" 
android:gravity="center"  //you can give gravity to line as you want
android:width="match_parent"  // you can give width as much u want
android:height="2dp"  //here its 2dp which gives thickness to the line
android:src="#000000"/>  //line will be black color change color of your choice

这些将在activity.xml文件中为您创建行,因此在此下方您可以绘制三角形。希望这会对你有所帮助。

相关问题