Android Irregular View

About this Project

An android view that enable clip foreground and background into irregular shape

Core Ability

  • foreground drawable
  • background drawable
  • foreground border
  • background border
  • clip drawable into any shape
  • clip by path or round corners

Steps for Integration

1. Dependency
api("io.github.hellogoogle2000:android-irregular-view:1.0.1")
2. Apply in Xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:gravity="center"
    android:orientation="vertical">

    <com.android.library.irregularview.IrregularView
        android:id="@+id/irregularView1"
        android:layout_width="150dp"
        android:layout_height="120dp"
        android:background="#2200FF00"
        android:padding="5dp"
        app:foreground="@drawable/ic"
        app:foregroundBorderColor="#FF00FF"
        app:foregroundBorderWidth="5dp"
        app:foregroundOutline="Path"
        app:foregroundPathData="M 0 50 L 0 0 L 100 0 L 100 50 A 50 50 0 0 1 0 50 Z" />

    <com.android.library.irregularview.IrregularView
        android:id="@+id/irregularView2"
        android:layout_width="150dp"
        android:layout_height="120dp"
        android:layout_marginTop="10dp"
        android:background="#2200FF00"
        android:padding="5dp"
        app:foreground="@drawable/ic"
        app:foregroundBorderColor="#FF00FF"
        app:foregroundBorderWidth="5dp"
        app:foregroundBottomRightRadius="20%"
        app:foregroundOutline="RoundRect"
        app:foregroundTopLeftRadius="20%" />

    <com.android.library.irregularview.IrregularView
        android:id="@+id/irregularView3"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_marginTop="10dp"
        app:background="@color/blue_percent_50"
        app:backgroundOutline="Path"
        app:backgroundPathData="M 50 0 A 50 50 0 0 0 50 100 A 50 50 0 0 0 50 0"
        app:foreground="@color/red_percent_50"
        app:foregroundCornerRadius="20%"
        app:foregroundOutline="RoundRect" />
</LinearLayout>
3. Cautions
  • path will be scaled to fill content size
  • round corners is defined in fraction
  • master basic knowledge of path, if you want to accomplish any shape
4. Supported Attributes
  • foreground
  • foregroundOutline
  • foregroundPathData
  • foregroundCornerRadius
  • foregroundTopLeftRadius
  • foregroundTopRightRadius
  • foregroundBottomLeftRadius
  • foregroundBottomRightRadius
  • foregroundBorderColor
  • foregroundBorderWidth
  • background
  • backgroundOutline
  • backgroundPathData
  • backgroundCornerRadius
  • backgroundTopLeftRadius
  • backgroundTopRightRadius
  • backgroundBottomLeftRadius
  • backgroundBottomRightRadius
  • backgroundBorderColor
  • backgroundBorderWidth

Preview

  • 82
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值