7

我需要在 Android 中创建收据布局。这个想法很简单,一个带有锯齿形顶部的矩形布局。

在此处输入图像描述

甚至,我尝试过虚线,但没有任何效果。

<shape xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="line">

<stroke
   android:color="#FF00"
   android:dashWidth="5dp"
   android:dashGap="5dp" />
</shape>
4

3 回答 3

7

试试这个:https ://github.com/beigirad/ZigzagView

支持topbottom之字形。

<ir.beigirad.zigzagview.ZigzagView
    android:layout_width="match_parent"
    android:layout_height="240dp"
    app:zigzagBackgroundColor="#8bc34a"
    app:zigzagElevation="8dp"
    app:zigzagHeight="10dp"
    app:zigzagShadowAlpha="0.9"
    app:zigzagSides="top|bottom"
    app:zigzagPaddingContent="16dp">

    // add child view(s)

</ir.beigirad.zigzagview.ZigzagView>

之字形视图

于 2018-05-16T17:23:53.183 回答
2

您好,您可以使用这个库android-shape-imageview。并使用这样的透明形状

最终用途库。

在此处输入图像描述

<com.github.siyamed.shapeimageview.mask.PorterShapeImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:siShape="@drawable/zigzag"
android:src="@drawable/neo"
app:siSquare="true"/>

在此处输入图像描述

您可以更改app:siShape="@drawable/zigzag"为所需的形状。您可以创建其他 png 形状。

于 2016-10-26T04:54:12.413 回答
1

创建小三角形并使用重复背景

重复背景.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/imagename"
    android:tileMode="repeat" />

并在任何视图中使用它

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/repeat_background" />

参考thisthis了解更多

于 2016-10-26T04:40:09.057 回答