android-shape-imageview


Source link: https://github.com/siyamed/android-shape-imageview

Shape Image View

Provides a set of custom shaped android imageview components, and a framework to define more shapes. Implements both shader and bitmap mask based image views.

  • Shader based one uses canvas draw methods and Path class,
  • Mask based one uses xfermode to draw image on bitmaps defined by android shape XML's or resource bitmaps.

There are many projects online implementing such components, however one goal of this project is to provide a performant/smooth scrolling image view component framework to define different shapes for imageviews.

For use with recycling view such as ListView or GridView please use shader based implementations.

Sample app in play store

Youtube video

How to use

Gradle dependency:

compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'

###Shader Based ImageView's ####BubbleImageView

<com.github.siyamed.shapeimageview.BubbleImageView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:src="@drawable/neo"
  app:siArrowPosition="right"
  app:siSquare="true"/>

Attributes:

  • siTriangleHeight the height of the bubble pointer in dp
  • siArrowPosition where to point the arrow, currently left|right
  • siSquare set width and height to the minimum of the given values true|false

####RoundedImageView

<com.github.siyamed.shapeimageview.RoundedImageView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:src="@drawable/neo"
  app:siRadius="6dp"
  app:siBorderWidth="6dp"
  app:siBorderColor="@color/darkgray"
  app:siSquare="true"/>

Attributes:

  • siBorderColor border color
  • siBorderWidth border width in dp
  • siBorderAlpha alpha value of the border between 0.0-1.0
  • siRadius corner radius in dp
  • siSquare set width and height to the minimum of the given values true|false

####CircularImageView

<com.github.siyamed.shapeimageview.CircularImageView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:src="@drawable/neo"
  app:siBorderWidth="6dp"
  app:siBorderColor="@color/darkgray"/>

Attributes:

  • siBorderColor border color
  • siBorderWidth border width in dp
  • siBorderAlpha alpha value of the border between 0.0-1.0

####ShapeImageView This view has the capability to process a provided SVG file (for a limited set of SVG elements), build a Path object and draw it on the shader. The library includes SVG files defining a set of basic shapes and ShapeImageView subclasses using those files. You can use whatever SVG you want to have a wonderful and creatively shaped images in your application. The included SVG files are under library/src/main/res/raw

DiamondImageView PentagonImageView HexagonImageView
OctogonImageView StarImageView HeartImageView
<com.github.siyamed.shapeimageview.{
ClassName
}

  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_margin="8dp"
  android:src="@drawable/neo"
  app:siBorderWidth="8dp"
  app:siBorderColor="@color/darkgray"/>

Attributes:

  • siBorderColor border color
  • siBorderWidth border width in dp
  • siBorderAlpha alpha value of the border between 0.0-1.0
  • siStrokeCap border stroke cap type butt|round|square
  • siStrokeJoin border stroke join type bevel|miter|round
  • siSquare set width and height to the minimum of the given values true|false
  • siShape a reference to an SVG. This is used by ShapeImageView, not the subclasses of it.

SVG elements that are supported are: rectangle, circle, ellipse, polygon, path, group. Transformations on those elements are also supported.

The system converts an SVG file into a Path. For each element including the parent element <svg> a new Path is created, and all the children Path's are added to their parent path.

###Bitmap Mask Based ImageViews

This view uses extra bitmaps for bitmap masks. Therefore it would be good to use them for very custom shapes, possibly not in a recycling view.

<com.github.siyamed.shapeimageview.mask.PorterShapeImageView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:siShape="@drawable/star"
  android:src="@drawable/neo"
  app:siSquare="true"/>

<com.github.siyamed.shapeimageview.mask.PorterShapeImageView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:siShape="@drawable/shape_rounded_rectangle"
  android:src="@drawable/neo"
  app:siSquare="true"/>

rounded rectangle shape definition in XML:

<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
  <corners

android:topLeftRadius="18dp"

android:topRightRadius="18dp"

android:bottomLeftRadius="18dp"

android:bottomRightRadius="18dp" />
  <solid android:color="@color/black" /> </shape>

Attributes:

  • siShape the bitmap mask shape, either a shape drawable or a bitmap
  • siSquare set width and height to the minimum of the given values true|false

This method reads a shape file (either bitmap or an android shape xml), creates a bitmap object using this shape, and finally combines the bitmap of the real image to be shown and the mast bitmap using xfermode.

Sample

See/execute the sample for a demonstration of the components.

If you are lazy check this youtube video demonstrating scrolling in the sample app

You can download the sample app from play store

Proguard

-dontwarn android.support.v7.** -keep class android.support.v7.** {
 ; 
}
 -keep interface android.support.v7.* {
 ; 
}
 -keepattributes *Annotation,Signature -dontwarn com.github.siyamed.** -keep class com.github.siyamed.shapeimageview.**{
 *; 
}
 

References

Resources

CaptchaImageView is a custom imageview to generate captcha text.

A RecyclerView adapter that can handle holding hetrogeneuous data types, and provides the ability to set up sections in your adatper.

Kotlin Language Integrated Production System (KLIPS)

A rule based AI engine to simplify design of AIs for games in particular. DSL included!

An observable Finite State Machine for Java.

Useful when you have a number of distinct states, with some optional state transitions, and associated actions.

For example, you may have states ON_CALL and OFF_CALL, with triggers START_CALL and END_CALL, with an assocoated action to print the call length when END_CALL is received.

An Implementation of WebView with Ad-blocked Interface. Blocks Banner And Video Apps From Web Page

Eleven music player (CyanogenMod) - compatible with Android version > 14.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes