gpt4 book ai didi

Android:使用形状绘制 "X"

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:40:07 25 4
gpt4 key购买 nike

需要使用ShapesView 中绘制“X”,但X 的边缘必须锚定在 View 的左、上、右和底部。

像这样:

sample image

最佳答案

通过可绘制的 xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
<rotate
android:fromDegrees="135"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="135">
<shape android:shape="line">
<stroke android:width="1dp" android:color="@color/social_grey" />
</shape>
</rotate>
</item>
<item>
<rotate
android:fromDegrees="45"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="45">
<shape android:shape="line">
<stroke android:width="1dp" android:color="@color/social_grey" />
</shape>
</rotate>
</item>


</layer-list>

带填充:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:left="4dp"
android:right="4dp"
>
<rotate
android:fromDegrees="135"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="135">
<shape android:shape="line">
<stroke android:width="1dp" android:color="@color/social_grey" />
</shape>
</rotate>
</item>
<item
android:left="4dp"
android:right="4dp"
>
<rotate
android:fromDegrees="45"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="45">
<shape android:shape="line">
<stroke android:width="1dp" android:color="@color/social_grey" />
</shape>
</rotate>
</item>
</layer-list>

关于Android:使用形状绘制 "X",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11086985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com