Giter Site home page Giter Site logo

imagewindow's Introduction

ImageWindow

An image with a close button like Google Messenger attachments.

Explained in this blog : http://androidshenanigans.blogspot.pt/2015/02/imagewindow-image-view-like-google.html

Integration

Step 1. Add the JitPack repository to your build file

repositories {
    maven {
        url "https://jitpack.io"
    }
}

Step 2. Add the dependency

dependencies {
	        compile 'com.github.kanytu:ImageWindow:v1.0'
}

Usage

Add ImageWindow to your xml:

 <com.poliveira.apps.imagewindow.ImageWindow
     android:layout_width="350dp"
     android:layout_height="wrap_content"
     android:id="@+id/myImageView"/>

XML attributes:

app:close_color - color of the close button (default = 0xffff7b57)
app:close_margin - margin for the close button (default = 5dp)
app:close_size - size of the close button (default = 32dp)
app:corner_radius - corner radius for the ImageView (default = 7dp)
app:image_margin - top and left margin of the ImageView (default = 10dp)
app:close_icon - close drawable (default = ic_action_close)

Set an image to it on your activity:

ImageWindow myImageWindow = (ImageWindow) findViewById(R.id.myImageView);
myImageWindow.getImageView().setImageResource(R.drawable.myCat);

Set a delete callback for when you click on the close button

myImageWindow.setOnCloseListener(new ImageWindow.OnCloseListener() {
        @Override
        public void onCloseClick(final View imageWindow) {
            imageWindow.animate().alpha(0).setDuration(500).setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    ((ViewGroup) (imageWindow.getParent())).removeView(imageWindow);
                }
            }).start();
        }
});

RESULT

ImageWindow

Android Arsenal

imagewindow's People

Contributors

kanytu avatar

Watchers

James Cloos avatar Nikhil avatar

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.