作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试为我的 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
,但是您可以使用任何其他 View 。
这是 View
<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>
这是它的样子:
关于android - 如何创建平行四边形形状的背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29094070/
我有点困惑:我想创建一些平行四边形并将文本放入其中。但是当我将文本放入其中时,文本与平行四边形的形状对齐。这是我试过的 .parallelogram { width: 130px; heigh
我使用 CSS3 的 skew 变换制作了一个平行四边形,并将文本放置在另一个具有相反 skew 值的 div 中,以便文本保持未变换: JSFiddle example . 有没有办法让文本像这样对
这个问题在这里已经有了答案: Shape with a slanted side (responsive) (3 个答案) 关闭 7 年前。 我正在尝试仅使用 CSS(白色表单)制作此表单: 但是我
需要将菜单栏的棱 Angular 绘制为 内部内容可能是一些标签或链接。 最佳答案 如何使用 CSS3 transform skew ? Demo .shape { width: 200px;
我是一名优秀的程序员,十分优秀!