• Stars
    star
    3,132
  • Rank 14,345 (Top 0.3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Give a custom shape to any android view, Material Design 2 ready

ShapeOfView

CircleCI

Give a custom shape to any android view Useful for Material Design 2

screen screen screen

Android app on Google Play

Breaking change

the old package com.github.florent37 has been replaced by io.github.florent37

Download

Buy Me a Coffee at ko-fi.com

Download

//using maven central

dependencies {
    implementation 'io.github.florent37:shapeofview:1.4.7'
}

Sample

What you can do with Shape Of View :

screen

Use implemented shapes

ShapeOfView disable the background property of your view, please specify a child with a background to enable it

<io.github.florent37.shapeofview.shapes.CircleView
   <FrameLayout
      android:background="@color/blue"

ShapeOfView came with pre-created shapes :

Circle

screen

<io.github.florent37.shapeofview.shapes.CircleView
        android:layout_width="150dp"
        android:layout_height="150dp"

        android:elevation="4dp"
        app:shape_circle_borderColor="@android:color/black"
        app:shape_circle_borderWidth="2dp">

            <!-- YOUR CONTENT -->

</io.github.florent37.shapeofview.shapes.CircleView>

RoundRect

screen

<io.github.florent37.shapeofview.shapes.RoundRectView
        android:layout_width="150dp"
        android:layout_height="100dp"
        android:elevation="4dp"
        app:shape_roundRect_bottomLeftRadius="10dp"
        app:shape_roundRect_bottomRightRadius="10dp"
        app:shape_roundRect_topLeftRadius="10dp"
        app:shape_roundRect_topRightRadius="10dp"
        
        app:shape_roundRect_borderColor="@android:color/black"
        app:shape_roundRect_borderWidth="2dp"
        >


            <!-- YOUR CONTENT -->

</io.github.florent37.shapeofview.shapes.RoundRectView>

ClipCorner

screen

<io.github.florent37.shapeofview.shapes.CutCornerView
        android:id="@+id/clipCorner"
        android:layout_width="150dp"
        android:layout_height="100dp"
        android:elevation="4dp"
        app:shape_cutCorner_bottomRightSize="20dp">

         <!-- YOUR CONTENT -->

</io.github.florent37.shapeofview.shapes.CutCornerView>

Arc

screen

<io.github.florent37.shapeofview.shapes.ArcView
        android:layout_width="150dp"
        android:layout_height="100dp"
        android:elevation="4dp"
        app:shape_arc_cropDirection="outside"
        app:shape_arc_height="20dp"
        app:shape_arc_position="bottom"
        >

         <!-- YOUR CONTENT -->

</io.github.florent37.shapeofview.shapes.ArcView>

Diagonal

screen

<io.github.florent37.shapeofview.shapes.DiagonalView
        android:layout_width="150dp"
        android:layout_height="100dp"
        android:elevation="4dp"
        app:shape_diagonal_angle="10"
        app:shape_diagonal_direction="right" 
        app:shape_diagonal_position="bottom">

         <!-- YOUR CONTENT -->

</io.github.florent37.shapeofview.shapes.DiagonalView>

Triangle

screen

<io.github.florent37.shapeofview.shapes.TriangleView
         android:layout_width="150dp"
         android:layout_height="150dp"
         android:elevation="4dp"

         app:shape_triangle_percentBottom="0.5"
         app:shape_triangle_percentLeft="0"
         app:shape_triangle_percentRight="0">

            <!-- YOUR CONTENT -->

</io.github.florent37.shapeofview.shapes.TriangleView>

Bubble

screen

<io.github.florent37.shapeofview.shapes.BubbleView
        android:layout_width="150dp"
        android:layout_height="150dp"
        app:shape_bubble_arrowHeight="10dp"
        app:shape_bubble_arrowWidth="10dp"
        app:shape_bubble_arrowPosition="bottom"
        app:shape_bubble_borderRadius="20dp"
        app:arrow_posititon_percent="0.5"
        >

         <!-- YOUR CONTENT -->

</io.github.florent37.shapeofview.shapes.BubbleView>

Star

screen screen

<io.github.florent37.shapeofview.shapes.StarView
        android:layout_width="150dp"
        android:layout_height="150dp"
        app:shape_star_noOfPoints="5">

         <!-- YOUR CONTENT -->

</io.github.florent37.shapeofview.shapes.StarView>

Polygon

screen

 <io.github.florent37.shapeofview.shapes.PolygonView
            android:layout_width="150dp"
            android:layout_height="100dp"
            app:shape_polygon_noOfSides="9"
            >
         <!-- YOUR CONTENT -->

</io.github.florent37.shapeofview.shapes.PolygonView>

Dotted Edges with Cut Corners

screen

 <io.github.florent37.shapeofview.shapes.DottedEdgesCutCornerView
             android:layout_width="100dp"
             android:layout_height="match_parent"
             app:shape_dot_radius="3dp"
             app:shape_dot_spacing="2dp"
             app:shape_edge_position="right|left"
             app:shape_dottedEdgesCutCorner_bottomLeftSize="8dp"
             app:shape_dottedEdgesCutCorner_bottomRightSize="8dp"
             >

             <!-- YOUR CONTENT -->

 </io.github.florent37.shapeofview.shapes.DottedEdgesCutCornerView>

Animation

All shapes methods can be animated

For example, you can animate a RoundRect corner :

anim

ValueAnimator.ofFloat(0f, 200f, 0f).apply {
     addUpdateListener { animation -> roundRect.bottomLeftRadius = (animation.animatedValue as Float).toInt() }
     duration = 800
     repeatCount = ValueAnimator.INFINITE
     repeatMode = ValueAnimator.REVERSE
}.start()

Create you own shape

You can use custom shape to cut your view

Using Drawable (no elevation)

screen

<io.github.florent37.shapeofview.ShapeOfView
        android:layout_width="100dp"
        android:layout_height="100dp"

        app:shape_clip_drawable="@drawable/YOUR_DRAWABLE"
        >

    <!-- YOUR CONTENT -->

 </io.github.florent37.shapeofview.ShapeOfView>

Using Path (with elevation)

This method generates also a shadow path (with Lollipop elevation API 21+)

Wrap your view with a ShapeOfView

<io.github.florent37.shapeofview.ShapeOfView
        android:id="@+id/myShape"
        android:layout_width="30dp"
        android:layout_height="15dp"
        android:elevation="6dp">

        <!-- YOUR CONTENT -->

 </io.github.florent37.shapeofview.ShapeOfView>

Then generate a path in your code :

ShapeOfView shapeOfView = findViewById(R.id.myShape)
shapeOfView.setClipPathCreator(new ClipPathManager.ClipPathCreator() {
       @Override
       public Path createClipPath(int width, int height) {
           final Path path = new Path();

            //eg: triangle
           path.moveTo(0, 0);
           path.lineTo(0.5 * width, height);
           path.lineTo(width, 0);
           path.close();

           return path;
       }
});

In some case you have to specify requiresBitmap = true to enable ShapeOfView to draw the shape inside a bitmap before clipping your view. It will be less efficient but can make your custom shape work.

Contribute

Feel free to fork this project, and add customs shapes

Then make a merge-request after updated the README with a sample of your shape, including a preview

TODO

HISTORY

1.4.5 Removed DiagonalView's Direction : if diagonalAngle > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT

1.4.5 Removed ArcView's ArcDirection : CROP_OUTSIDE if arcHeight > 0, CROP_INSIDE if arcHeight < 0

1.4.1 Added Dotted Edge, thanks to @khunzohn

1.4.0 Support AndroidX

1.3.2 Backport of 1.3.0 for api 14+

1.3.0 Fixed rendering on android API 28+

1.2.0 Removed bitmap usage in a lot of usecases (diagonal, arc, roundrect, circle)

1.1.0 Disabled setBackground on ShapeOfView

1.0.9 Added requiresShapeUpdate(), allowing animations to work, look at AnimationActivity

1.0.8 Used arcTo instead of quads in RoundRect, added border to RoundRect

1.0.7 Prefixed all attributes by shape_

1.0.6 Updated roundrect implementation

1.0.5 Enable hardware acceleration after clip view

1.0.4 Added PolygonView

1.0.2 Added StarView

1.0.1 Added BubbleView

Credits

Ed Sheeran, for the name of this project and his awesome songs <3

Author: Florent Champigny

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2017 Florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

MaterialViewPager

A Material Design ViewPager easy to use library
Java
8,130
star
2

ExpectAnim

Describe your animation and run !
Java
2,788
star
3

ViewAnimator

A fluent Android animation library
Java
2,712
star
4

DiagonalLayout

With Diagonal Layout explore new styles and approaches on material design
Java
2,562
star
5

CameraFragment

A simple easy-to-integrate Camera Fragment for Android
Java
2,290
star
6

ExpansionPanel

Android - Expansion panels contain creation flows and allow lightweight editing of an element.
Java
1,976
star
7

GlidePalette

Android Lollipop Palette is now easy to use with Glide
Java
1,677
star
8

ArcLayout

With Arc Layout explore new styles and approaches on material design
Java
1,638
star
9

MaterialTextField

A different beautiful Floating Edit Text
Java
1,488
star
10

HollyViewPager

A different beautiful ViewPager, with quick swipe controls
Java
1,131
star
11

FiftyShadesOf

An elegant context-care loading placeholder for Android
Java
1,107
star
12

ViewTooltip

A fluent tooltip for Android
Java
1,080
star
13

SingleDateAndTimePicker

You can now select a date and a time with only one widget !
Java
1,020
star
14

MyLittleCanvas

🎨Need to create a custom view ? You don't know how to use Canvas, use MyLittleCanvas instead !
Java
927
star
15

AwesomeBar

Just beautiful
Java
869
star
16

RuntimePermission

Simpliest way to ask runtime permissions on Android, no need to extend class or override permissionResult method, choose your way : Kotlin / Coroutines / RxJava / Java7 / Java8
Java
865
star
17

Depth

Add some Depth to your fragments
Java
779
star
18

Flutter-AssetsAudioPlayer

Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications
Dart
755
star
19

MaterialLeanBack

A beautiful leanback port for Smartphones and Tablets
Java
731
star
20

KotlinPleaseAnimate

Kotlin, please, can you animate my views ?
Kotlin
558
star
21

LongShadow

Add a long shadow on any Android View
Java
557
star
22

BubbleTab

Put some bubble in your tabs and give your apps a supa fresh style !
Java
533
star
23

TutoShowcase

A simple and Elegant Showcase view for Android
Java
509
star
24

RxRetroJsoup

A simple API-like from html website (scrapper) for Android, RxJava2 ready !
Java
485
star
25

Carpaccio

Data Mapping & Smarter Views framework for android
Java
414
star
26

BeautifulParallax

Beautify your RecyclerViews with a great parallax effect !
Java
410
star
27

MaterialImageLoading

Material image loading implementation
Java
390
star
28

PicassoPalette

Android Lollipop Palette is now easy to use with Picasso !
Java
365
star
29

android-slidr

Another android slider / seekbar, but different :-)
Java
346
star
30

Freezer

A simple & fluent Android ORM, how can it be easier ? RxJava2 compatible
Java
328
star
31

RxGps

Finding current location cannot be easier on Android !
Java
300
star
32

WearMenu

An Android Wear Menu implementation
Java
289
star
33

Android-NoSql

Lightweight, simple structured NoSQL database for Android
Java
288
star
34

InlineActivityResult

Receive the activity result directly after the startActivityForResult with InlineActivityResult
Java
273
star
35

Motion-ShapeOfView

Explain how to use MotionLayout with ShapeOfView
Kotlin
241
star
36

Android-3D-Layout

Wow effect, transform your layout into 3D views
Java
231
star
37

OCiney-iOS

Objective-C
227
star
38

NewAndroidArchitecture-Component-Github

Sample project based on the new Android Component Architecture
Java
222
star
39

DaVinci

DaVinci is an image downloading and caching library for Android Wear
Java
219
star
40

Flutter-ShapeOfView

Give a custom shape to any flutter widget, Material Design 2 ready
Dart
216
star
41

Shrine-MaterialDesign2

implementation of Material Design 2 Shrine project
Kotlin
216
star
42

AndroidUnitTest

Save time & clear your unit tests on Android !
Java
205
star
43

AndroidParallax

Parallax on Android in the simplest way
Java
173
star
44

ApplicationProvider

Retrieve the android application and the current activity from anywhere
Kotlin
165
star
45

Navigator

Android Multi-module navigator, trying to find a way to navigate into a modularized android project
Kotlin
142
star
46

Android-YoutubeMp3

Download videos as mp3 directly from Youtube Android App
Java
136
star
47

KotlinNativeSample

Kotlin Native app working on Android & iPhone
Kotlin
120
star
48

EnhancedNavigationView

A different BottomNavigationView that you could find in all android apps
Kotlin
114
star
49

AnimatedWidgets

Easily add animations on your screen with AnimatedWidgets. Made for Bloc pattern
Dart
113
star
50

OCiney

OCiney is a sample app implementing several UI and UX patterns. I was firstly built to test a few different implementations of a details page.
Java
110
star
51

Kanvas

Make canvas easier to use in Kotlin 😊
Kotlin
98
star
52

Multiplatform-LiveData

Multiplatorm implementation of LiveDatas / MVVM in kotlin android & native ios
Kotlin
94
star
53

movie_android_flutter

A sample movie app, developed on flutter, then on android
Dart
87
star
54

Multiplatform-Preferences

Kotlin Multi Platform Preferences, for android an ios : SharedPreferences & NSUserDefault
Kotlin
86
star
55

Flutter-KenBurns

Kenburns effect on flutter
Dart
84
star
56

RxAnimator

An RxJava2 binding for android Animator
Java
79
star
57

WearViewStub

Display different layout on Android Wear Square / Round / Moto 360
Java
79
star
58

RxBus

Android reactive event bus that simplifies communication between Presenters, Activities, Fragments, Threads, Services, etc.
Java
77
star
59

TutosAndroidFrance

Java
75
star
60

Google-ARCore-Playground

Exploring Augmented Reality with google's sdk ARCore
Java
72
star
61

KotlinAnim

Create fluent animations in a kotlin way
Kotlin
70
star
62

Android-OkGraphQl

Reactive GraphQl client for Android
Java
64
star
63

AnimatedPencil

Animated Pencil Action view for Android
Java
60
star
64

RxComponentLifecycle

Rx binding of new Android Architecture Component Lifecycle
Java
56
star
65

Multiplatform-Log

Kotlin Multi Platform Logger, for android an ios : Logcat & print
Kotlin
51
star
66

DaggerAutoInject

Inject automatically your Activities & Fragments, just with a simple annotation
Java
49
star
67

EasyFirebase

Java
48
star
68

fonts

Define the fonts of your Android project directly from the build.gradle
Groovy
46
star
69

Multiplatform-Bus

Kotlin event-bus compatible with Android & native iOS
Kotlin
44
star
70

flutter_web_import_js_library

Import & use javascript libraries in your flutter web projects
JavaScript
42
star
71

Wear-Emmet

Emmet is an protocol based data-transfer for Android Wear
Java
41
star
72

AndroidAnalytics

Analytics dispatcher for Android Applications
Java
39
star
73

RxAndroidOrm

An reactive simple & fluent Android ORM, how can it be easier ? RxJava2 ready
Java
36
star
74

Flutter-Anim

Fluent Flutter Animation library. Describe Sequences & Parallel animation's workflow, setup startDelay, duration and curve, then run !
Dart
36
star
75

WormHole

WormHole allows to share classes between Flutter and Native Platform (android / ios)
Dart
34
star
76

Github

Sample project using Dagger2, RxJAva, RetroLambda and Carpaccio
Java
31
star
77

Coroutines-Animations

Use the power of kotlin coroutines to execute your android animations
Kotlin
30
star
78

Potier

Java
29
star
79

RxBeacon

Rx binding for AltBeacon (Android-Beacon-Library)
Java
29
star
80

Open-Mam

Open Source Mobile Application Management (WORK IN PROGRESS)
Java
28
star
81

HolyFragment

Fragment NewInstance generator
Java
16
star
82

Flutter_audio_widget

Play an audio on flutter can be as simple as display an image ! Just add a widget into the tree
Dart
14
star
83

Asyncterractor

Transform any object into an async object (can be useful for VIPER)
Java
14
star
84

WearKit

Wearkit is an Android Wear implementation of WatchKit
Java
13
star
85

JsonSerializable-Plugin

Intellij Plugin for Dart and Flutter projects. Generates the code that JsonSerializable need to generate the .g.dart files
Java
12
star
86

Missing_Kotlin

"Flutter is **** because it does not use Kotlin" Already heard it ? Prove them you can do the same thing as Kotlin using Flutter/Dart !
Dart
11
star
87

Baguette

Baguette is an Android Toast implementation adapted for Android Wear
Java
10
star
88

AdsManager

Java
9
star
89

StickyHeader

Cannot have a simplest android recycler sticky header implementation
8
star
90

AndroidMVPresenter

Java
6
star
91

WatchFaceSample

Java
5
star
92

GCM-Sample-Android-PHP

Java
4
star
93

OSSRH-67799

3
star
94

flutter_web_howl

JavaScript
2
star
95

MeetupWear_EmmetDavinci

Java
2
star
96

OpenMam-PHP

JavaScript
1
star
97

OpenMam-Android

Java
1
star
98

MyYoutube

1
star
99

UnitTestWithDagger

Java
1
star