Android - 旋转切断形状的角落 [英] Android - rotate cuts off corners of shape

查看:170
本文介绍了Android - 旋转切断形状的角落的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望制作一个钻石作为资源文件,所以我正在旋转一个正方形以便这样做。问题是角落似乎被切断了,改为制作六角形。另外作为一个附注,如果可能的话,我想垂直拉伸它。

I wish to make a diamond as a resource file so I am rotating a square in order to do so. The problem is that the corners seem to be getting cut off, making a hexagon instead. Also as a side note, I'd like to stretch it vertically if that's possible.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <rotate
        android:fromDegrees="45"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="45"
        >
        <shape android:shape="rectangle">
            <size
                android:height="40dp"
                android:width="40dp" />
            <solid
                android:color="@color/level_1_color" />
        </shape>
    </rotate>
</item>

推荐答案

如何:

**<item android:left="5dp" android:right="5dp" android:top="5dp" android:bottom="5dp">**
    <rotate
        android:fromDegrees="45"
        android:toDegrees="45" >
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">

            <solid
                android:color="@color/sym_orange_bdfm"/>

            <size
                android:width="23dp"
                android:height="23dp"/>
        </shape>
    </rotate>
</item>

根据需要调整左/右/上/下。

Adjust Left/Right/Top/Bottom as needed.

这篇关于Android - 旋转切断形状的角落的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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