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
kotlin 复制代码
api("io.github.hellogoogle2000:android-irregular-view:1.0.1")
2. Apply in Xml
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

相关推荐
帅得不敢出门7 小时前
安卓设备adb执行AT指令控制电话卡
android·adb·sim卡·at指令·电话卡
我又来搬代码了9 小时前
【Android】使用productFlavors构建多个变体
android
德育处主任10 小时前
Mac和安卓手机互传文件(ADB)
android·macos
芦半山10 小时前
Android“引用们”的底层原理
android·java
迃-幵11 小时前
力扣:225 用队列实现栈
android·javascript·leetcode
大风起兮云飞扬丶11 小时前
Android——从相机/相册获取图片
android
Rverdoser11 小时前
Android Studio 多工程公用module引用
android·ide·android studio
aaajj12 小时前
[Android]从FLAG_SECURE禁止截屏看surface
android
@OuYang12 小时前
android10 蓝牙(二)配对源码解析
android
Liknana12 小时前
Android 网易游戏面经
android·面试