Custom ImageView for android with polygon shape (Android)

Overview

PolygonImageView

Create a custom ImageView with polygonal forms.

Android Arsenal

Demo Screenshot 1 Demo Screenshot 2 Demo Screenshot 3

Usage

To use PolygonImageView, add the module into your project and start to build xml or java.

XML

    <net.grobas.view.PolygonImageView
        android:layout_width="250dp"
        android:layout_height="250dp"
        android:src="@drawable/cat07"
        app:poly_shadow="true"
        app:poly_shadow_color="@android:color/black"
        app:poly_border="true"
        app:poly_border_color="@android:color/white"
        app:poly_vertices="6"
        app:poly_border_width="5dp"
        app:poly_corner_radius="5"
        app:poly_rotation_angle="25" />
Properties:
  • app:poly_vertices (integer) -> default 5
    • 0 -> Circle
    • 1 -> Regular ImageView, no affected by other properties
    • 2 -> Square
    • >2 -> Polygon form
  • app:poly_shadow (boolean) -> default false
  • app:poly_shadow_color (color) -> default Black
  • app:poly_border (boolean) -> default false
  • app:poly_border_color (color) -> default White
  • app:poly_border_width (dimension) -> default 4dp
  • app:poly_corner_radius (float) -> default 0.0f
  • app:poly_rotation_angle (float) -> default 0.0f

JAVA

    LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
    PolygonImageView view = new PolygonImageView(this);
    view.setImageResource(R.drawable.cat);
    view.addShadowResource(10f, 0f, 7.5f, R.color.shadow);
    view.addBorderResource(5, R.color.border);
    view.setCornerRadius(2);
    view.setVertices(5);
    view.setPolygonShape(new PaperPolygonShape(-15, 25));
    layout.addView(view);

Effects

There are 3 basic effects:

  • RegularPolygonShape
  • PaperPolygonShape
  • StarPolygonShape

Create your own effect overriding BasePolygonShape or interface PolygonShape.

License

Copyright 2014 Albert Grobas

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.
You might also like...
Android ImageView that handles animated GIF images
Android ImageView that handles animated GIF images

GifImageView Android ImageView that handles Animated GIF images Usage In your build.gradle file: dependencies { compile 'com.felipecsl:gifimageview:

Android ImageView that supports different radii on each corner.
Android ImageView that supports different radii on each corner.

SelectableRoundedImageView Note that this project is no longer maintained. Android ImageView that supports different radii on each corner. It also sup

ImageView with a tag on android
ImageView with a tag on android

SimpleTagImageView ImageView with a tag in android. So it's a ImageView. Demo ####Warning:When you set the round radius,the simpletagimageview scale t

Flickable ImageView for Android. It's like a view of twitter's detail image.
Flickable ImageView for Android. It's like a view of twitter's detail image.

FlickableView Flickable ImageView for Android. It's like a view of twitter's detail image. It's possible that other views animate with FlickableView.

Create parallax and any other transformation effects on scrolling android ImageView
Create parallax and any other transformation effects on scrolling android ImageView

Android Parallax Image View Creates effect such as vertical parallax, horizontal parallax etc. on android ImageView when it's being vertically or hori

Implementation of ImageView for Android that supports zooming, by various touch gestures.
Implementation of ImageView for Android that supports zooming, by various touch gestures.

PhotoView PhotoView aims to help produce an easily usable implementation of a zooming Android ImageView. [ Dependency Add this in your root build.grad

Create circular ImageView in Android in the simplest way possible
Create circular ImageView in Android in the simplest way possible

CircularImageView This is an Android project allowing to realize a circular ImageView in the simplest way possible. USAGE To make a circular ImageView

A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows
A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows

A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows.Provides fast canvas draw as no renderscript needed .The similar shadow blurred effects can also be seen in iOS Music App.

ImageView and FrameLayout with gestures control and position animation
ImageView and FrameLayout with gestures control and position animation

GestureViews ImageView and FrameLayout with gestures control and position animation. Main goal of this library is to make images viewing process as sm

Comments
  • Colour filter not working

    Colour filter not working

    I am trying apply colour filters to the PolygonImageViews but they are not working. My code:

       ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        ColorMatrixColorFilter filter = new ColorMatrixColorFilter(cm);
        view.setColorFilter(filter);
    

    Any help would be appreciated.

    enhancement 
    opened by narayanaraoR 2
  • Black square behind image

    Black square behind image

    In lollipop if I use a square image a black square appears behind. Removing setLayerType solves the problem but shadowing is not working.

    //Avoid known shadow problems
    if (Build.VERSION.SDK_INT > 13)
           setLayerType(LAYER_TYPE_SOFTWARE, mBorderPaint);
    
    bug 
    opened by AlbertGrobas 1
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
  • showing black background in api 21

    showing black background in api 21

    hi albert thanks for this very nice lib. i use it in my app but in api 21 polygone shows black background or transparent even if have parent with colored background.

    device-2015-12-02-110924

    this is my code

     PolygonImageView view = new PolygonImageView(getApplicationContext());
     view.setImageResource(R.color.info_MainBackColor);
    
     view.addBorderResource(5, R.color.info_MainBackColor);
     view.setCornerRadius(2);
     view.setVertices(6);
     imageLayout.addView(view);
    

    this is my layout

      <RelativeLayout 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:id="@+id/mainlay"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:background="@color/amber_600"
     RelativeLayout 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:id="@+id/mainlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/amber_600"
     >
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
    
               <RelativeLayout
            android:id="@+id/imageLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="30dp">
    </RelativeLayout>
    </LinearLayout>
    
    bug 
    opened by mohamadk 5
Owner
Albert Grobas
Android Developer in Movetia
Albert Grobas
Custom shaped android imageview components

Shape Image View Provides a set of custom shaped android imageview components, and a framework to define more shapes. Implements both shader and bitma

Siyamed SINIR 2.6k Mar 29, 2021
Custom ImageView for moving image around the screen (Android)

MovingImageView Create a custom ImageView for moving image around the screen. Usage To use MovingImageView, add the module into your project and start

Albert Grobas 819 Nov 18, 2022
Custom ImageView to generate captcha image.

CaptchaImageView Custom ImageView to generate captcha image. Add CaptchaImageView to your layout <test.jinesh.captchaimageviewlib.CaptchaImageView

Jinesh Francis 610 Oct 18, 2022
Implementation of ImageView for Android that supports zooming, by various touch gestures.

PhotoView PhotoView aims to help produce an easily usable implementation of a zooming Android ImageView. [ Dependency Add this in your root build.grad

Baseflow 18.4k Dec 30, 2022
A circular ImageView for Android

CircleImageView A fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi which itself is based on techniq

Henning Dodenhof 13.8k Mar 29, 2021
Adds touch functionality to Android ImageView.

TouchImageView for Android Capabilities TouchImageView extends ImageView and supports all of ImageView’s functionality. In addition, TouchImageView ad

Michael Ortiz 2.4k Mar 28, 2021
Android ImageView widget with zoom and pan capabilities

ImageViewTouch for Android ImageViewTouch is an android ImageView widget with zoom and pan capabilities. This is an implementation of the ImageView wi

Alessandro Crugnola 1.9k Jan 4, 2023
Android ImageView replacement which allows image loading from URLs or contact address book, with caching

Smart Image View for Android SmartImageView is a drop-in replacement for Android’s standard ImageView which additionally allows images to be loaded fr

James Smith 1.3k Dec 24, 2022
Implements pinch-zoom, rotate, pan as an ImageView for Android 2.1+

GestureImageView This is a simple Android View class which provides basic pinch and zoom capability for images. Can be used as a replacement for a sta

Jason 1.1k Nov 10, 2022