android三角形drawablw xml

标签 android drawable shapes

我想画一个等边三角形,我已经检查过了,但它是倒的。我想要一个看起来像下图的三角形。

三角形: enter image description here

三角形形状.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <rotate
            android:fromDegrees="45"
            android:toDegrees="45"
            android:pivotX="-40%"
            android:pivotY="87%" >
            <shape
                android:shape="rectangle" >
                <stroke android:color="#fff" android:width="1dp"/>
                <solid
                    android:color="#000" />
            </shape>
        </rotate>
    </item>
</layer-list>

目前看起来是这样的..

enter image description here

最佳答案

使用 Vector drawable 你可以实现如下形状:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="100dp"
    android:height="100dp"
    android:viewportHeight="100"
    android:viewportWidth="100">
    <group android:name="triableGroup">
        <path
            android:name="triangle"
            android:fillColor="@color/color_start_color_back"
            android:pathData="m 50,0 l 50,50 -100,0 z" />
    </group>
</vector>

输出:

enter image description here

希望对你有帮助。

关于android三角形drawablw xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35618650/

相关文章:

android - 如何在android的标题栏中显示进度指示器或进度条?

Android - 为另一个可绘制文件夹拍摄图像

Android:是否可以制作一个带有可绘制对象的列表,1 在上面,其他在下面?

java - 使用Andengine画圆

javascript - 每个面有 K 个顶点的 3D 点的三 Angular 剖分

processing - 当线条分割 Canvas 时,单独的形状 + 选择点以从数组中绘制形状

android - 如何在 Activity 中的视频播放器上叠加

java - Android WebView Word Wrapping 捏缩放文本内容

android - 我可以在 Android 模拟器中配置 gmail 吗?

android - SlidingDrawer 句柄的可绘制对象在哪里定义?