GithubHelp home page GithubHelp logo

mostafagazar / customshapeimageview Goto Github PK

View Code? Open in Web Editor NEW
1.6K 86.0 425.0 1.21 MB

A library for supporting custom shaped ImageView(s) using SVGs and paint shapes

Home Page: http://mostafagazar.github.io/CustomShapeImageView

License: Apache License 2.0

Java 100.00%

customshapeimageview's Introduction

CustomShapeImageView Demo (Play Store Demo)

A library for supporting custom shaped ImageView(s) using SVGs and paint shapes

You can also use this gist https://gist.github.com/MostafaGazar/ee345987fa6c8924d61b if you do not want to add this library project to your codebase.

Build Status Android Arsenal Android Weekly PayPal Donations Coverage Status

Usage

<com.meg7.widget.CustomShapeImageView
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:src="@drawable/sample"
    app:shape="circle"
    android:scaleType="centerCrop" />

<com.meg7.widget.CircleImageView
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:src="@drawable/sample"
    android:scaleType="centerCrop" />

<com.meg7.widget.RectangleImageView
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:src="@drawable/sample"
    android:scaleType="centerCrop" />

<com.meg7.widget.SvgImageView
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:src="@drawable/sample"
    app:svg_raw_resource="@raw/shape_star"
    android:scaleType="centerCrop" />

Download

Add the customshapeimageview dependency to your build.gradle file:

Maven Central

dependencies {
    ...
    compile 'com.mostafagazar:customshapeimageview:1.0.4'
    ...
}

Proguard

If you're using proguard for code shrinking and obfuscation, make sure to add the following:

   -keep class com.meg7.widget.** { *; }

Screenshots

main

Libraries used

Developed by

License

Copyright 2013-2016 Mostafa Gazar

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.

Donations

If you'd like to support this library, you could make a donation here:

PayPal Donation

customshapeimageview's People

Contributors

ayman-abdelghany avatar bitdeli-chef avatar cyburs avatar mostafagazar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

customshapeimageview's Issues

Add Border for the image view

Hi Mostafa,
I used your Circular ImageView, it was good.
But I need to add border for that circular image view. How can I do that.
Please help me in resolving this issue.
Thanks in advance.

SvgImageView cannot display image from url.

<com.meg7.widget.SvgImageView
android:id="@+id/iv_avatar"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="centerCrop"
app:svg_raw_resource="@raw/avatar" />
i have using Glide to load image from internet. but image cannot display on my UI. please help me to resolve this issues. thanks

Svg Relative Layout

Hi Mostafa,
Thanks for your amazing library. I wonder if i can apply the svg to a simple view not only to image view. Thanks in adavance.

José Costa

SvgImageView is not playing nicely with Picasso's fade-in effect

Great library! 💯

When the SvgImageView is used with Picasso without disabling the fade-in effect.
The image view looks greyed out as shown below

But when picasso fetches the bitmap from memory cache, it looks all good

Picasso's fade-in effect needed to be disabled, in order for it to work here, I'm wondering what could be the cause of this behaviour?

Image, not shape, supplied from url/online?

@MostafaGazar

I would like to know if it is possible to combine this with the Volley NetworkImageView to give a custom shape to images being provided from a remote database.

The reason is that I have a listview that recieves its content from a remote database and I need each image in the list(icons) to retain the shape defined in the xml with ShapeImageView. Any thoughts on how this could be done?

I'm not very educated with Java programming so I'm terrible at trying to create this but this is what I tried combining a modified version of CustomShapeImageView with NetworkImageView. Didn't exactly work like it did in my head. :/ Matter of fact it didn't work at all. Here's the link:

ShapedNetworkImage test

do not support padding properties

when i use padding property(even paddingLeft, paddingTop, paddingRight paddingBottom), i will get a cilpped shape image on the imageview

Image not drawing, please help ASAP?

I've added the classes to my project individually by hand since jitpack isn't working. I've added the SvgImageView to my layout and set the src image and svg image. Nothing set programatically within my main activity. When I run the app, neither the image or svg show. I'm getting "failed to draw image. Invalid float" from the logcat. Look at the end. Here's the logcat:

02-02 02:09:26.431 25127-25127/? I/art: Late-enabling -Xcheck:jni
02-02 02:09:26.921 25127-25164/com.curtrostudios.customspraycantest D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
02-02 02:09:26.941 25127-25127/com.curtrostudios.customspraycantest D/Atlas: Validating map...
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:26.951 25127-25127/com.curtrostudios.customspraycantest W/Atlas: Pointer 0x0, not in getPreloadedDrawables?
02-02 02:09:27.101 25127-25164/com.curtrostudios.customspraycantest W/Adreno-GSL: <get_panel_settings:3802>: Android framework reported version 2. So, don't force ES30
02-02 02:09:27.101 25127-25164/com.curtrostudios.customspraycantest I/Adreno-EGL: <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_KK_2.7_RB1.04.04.00.007.018_msm8960_KK_2.7_RB1_CL3869936_release_AU (CL3869936)
OpenGL ES Shader Compiler Version: 17.01.10.SPL
Build Date: 12/09/13 Mon
Local Branch: mybranch2092625
Remote Branch: quic/kk_2.7_rb1.15
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_KK_2.7_RB1.04.04.00.007.018 + NOTHING
02-02 02:09:27.101 25127-25164/com.curtrostudios.customspraycantest I/OpenGLRenderer: Initialized EGL, version 1.4
02-02 02:09:27.111 25127-25164/com.curtrostudios.customspraycantest D/OpenGLRenderer: Enabling debug mode 0
02-02 02:09:27.222 25127-25127/com.curtrostudios.customspraycantest I/art: WaitForGcToComplete blocked for 5.981ms for cause Explicit
02-02 02:09:27.262 25127-25127/com.curtrostudios.customspraycantest I/art: Explicit concurrent mark sweep GC freed 87(28KB) AllocSpace objects, 0(0B) LOS objects, 38% free, 25MB/41MB, paused 824us total 40.439ms
02-02 02:09:27.272 25127-25127/com.curtrostudios.customspraycantest E/BaseImageView: Failed to draw, Id :: 2131558511. Error occurred :: com.curtrostudios.customspraycantest.SVGParseException: java.lang.NumberFormatException: Invalid float: "147.000000pt"
02-02 02:09:27.332 25127-25127/com.curtrostudios.customspraycantest E/BaseImageView: Failed to draw, Id :: 2131558511. Error occurred :: com.curtrostudios.customspraycantest.SVGParseException: java.lang.NumberFormatException: Invalid float: "147.000000pt"
02-02 02:09:27.472 25127-25127/com.curtrostudios.customspraycantest E/BaseImageView: Failed to draw, Id :: 2131558511. Error occurred :: com.curtrostudios.customspraycantest.SVGParseException: java.lang.NumberFormatException: Invalid float: "147.000000pt"
02-02 02:09:27.542 25127-25127/com.curtrostudios.customspraycantest E/BaseImageView: Failed to draw, Id :: 2131558511. Error occurred :: com.curtrostudios.customspraycantest.SVGParseException: java.lang.NumberFormatException: Invalid float: "147.000000pt"
02-02 02:09:27.542 25127-25127/com.curtrostudios.customspraycantest I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@d63094a time:22930766

Issue with scaleType

Issue with scaleType="center" when set an image in runtime. Image shown as centerCrop instead.

Images show up translucent. Get corrected on going back and opening the screen again

When the grid/list is created for the first time and images loaded into the image view via Picasso's lazy loading library, the images show up translucent. I set a placeholder image by default for all the image views and then lazy load the downloaded images into the same image view.

If I go back to the previous screen and open the screen again, all images show up correctly.

Am I doing anything wrong by setting a default placeholder image? Or is the lazy loading library - Picasso causing this?

how can i import this...?

i can't import this into eclipse ..
i try to run sample of this project but many errors this projects have..
i cant run sample and i think i cant import lib into eclipse..
can you help me..plz..thanks

Maven submission?

Any plans to upload this to the Maven repository for easier way to include this library in an Android Studio project?

Pinch and zoom

Is it possible to add pinch and zoom to just image and not the whole shape?
And if yes please suggest me way to do it. I have tried it but it zoom whole shape and not the image inside it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.