Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a squircle ImageView with Android

Is it possible to make an ImageView into a squircle? i.e not just rounded corners but a squircle? If so, how do you do it?

Basically, I want a list of icons that are squircles, so doing it in XML and setting the background on widget would be ideal.

like image 455
MSpeed Avatar asked May 11 '17 13:05

MSpeed


People also ask

How do I make an image circular in Android?

Simply put a circular_crop. png in your drawable folder which is in the shape of your image dimensions (a square in my case) with a white background and a transparent circle in the center. You can use this image if you have want a square imageview.

What is Squircle Android?

A fast and free multi-language code editor and file manager for Android.


1 Answers

https://github.com/MicroRJ/Android_Superellipse_Library

allprojects {
    repositories {          
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
            implementation 'com.github.MicroRJ:Android-Canvas-Squircle:1.0'
}

 <com.microdevrj.superellipse.custom_superellipse_views.SuperEllipseImageView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_gravity="center"
    android:padding="64dp"
    app:colorFill="@color/colorFill"
    app:colorStroke="@color/colorStroke"
    app:paintStyle="fillAndStroke"
    app:strokeWidth="6dp" />

Feel free to look at the open-source files to learn how it works.

A Squircle

like image 91
MicroRJ Avatar answered Oct 02 '22 15:10

MicroRJ