我正在尝试为我的textview制作平行四边形背景,但它没有正确显示…它显示以下输出
<layer-list > <item> <rotate android:fromdegrees="10" android:todegrees="10" android:pivotX="-40%" android:pivotY="87%" > <shape android:shape="rectangle" > <stroke android:color="#000000" android:width="10dp"/> </shape> </rotate> </item> </layer-list>
我需要像这样的输出……..
解决方法
作为@ mmlooloo的回答的替代方案,我建议使用xml-drawable解决方案(因为你还没有强调你正在寻找什么样的解决方案).在下面的示例中,我使用了一般视图,但您可以使用任何其他视图.
这是视图
<View android:layout_width="100dp" android:layout_height="40dp" android:layout_centerInParent="true" android:background="@drawable/shape" />
和shape.xml本身
<?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <!-- Colored rectangle--> <item> <shape android:shape="rectangle"> <size android:width="100dp" android:height="40dp" /> <solid android:color="#13a89e" /> </shape> </item> <!-- This rectangle for the left side --> <!-- Its color should be the same as layout's background --> <item android:right="100dp" android:left="-100dp" android:top="-100dp" android:bottom="-100dp"> <rotate android:fromdegrees="45"> <shape android:shape="rectangle"> <solid android:color="#ffffff" /> </shape> </rotate> </item> <!-- This rectangle for the right side --> <!-- Their color should be the same as layout's background --> <item android:right="-100dp" android:left="100dp" android:top="-100dp" android:bottom="-100dp"> <rotate android:fromdegrees="45"> <shape android:shape="rectangle"> <solid android:color="#ffffff" /> </shape> </rotate> </item> </layer-list>
它是这样的:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。