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

相关推荐
沈剑心4 分钟前
Kotlin的协程,真能提升编程效率么?
android·前端·kotlin
睡觉待开机1 小时前
【Android】03-Android 开发机器配置要求
android
Rverdoser2 小时前
非线性优化--NLopt算法(Android版本和Python示例)
android·python·算法
大胃粥3 小时前
Android V app 冷启动(6) Transition 数据化
android
帅次3 小时前
Flutter:StatelessWidget vs StatefulWidget 深度解析
android·flutter·ios·小程序·swift·webview·android-studio
好看资源平台4 小时前
安卓逆向环境搭建(Windows/Linux双平台)
android·linux·windows
林奋斗同学4 小时前
Android GMS集成
android
_一条咸鱼_5 小时前
Android Glide 框架线程管理模块原理的源码级别深入分析
android
_一条咸鱼_5 小时前
Android Retrofit 框架注解定义与解析模块深度剖析(一)
android
法欧特斯卡雷特5 小时前
Kotlin Sequence 真的如此不堪吗?
android·后端·编程语言