Skip to content

It's an Android View that can display image looking like Twitter's image display

License

Notifications You must be signed in to change notification settings

lekaha/TwitterizedPhotoView

Repository files navigation

TwitterizedPhotoView

Download Build

A view that shows the image with transition animation and the background color is extracting from the image. The transition animation is moving and scaling the image from origin position to the center of screen, and scale the image to fit the width of screen. When showing the image the background color of the screen will be determine by extracting the image's prominent dark color.

Pre-requisites

  • Android SDK 26
  • Android Build Tools v26.0.0
  • Android Support Repository ( check importance)
  • Android Support Library v26.0.0

Download

Use Gradle:

dependencies {
  compile 'com.github.lekaha:twitterized-photo-view:0.0.5'
}

Usage

  • Passing the showing image's URL:
String transitionName = ViewCompat.getTransitionName(imageView);
Intent intent = new Intent(context, TwitterizedImageShowingActivity.class);
intent.putExtra(TwitterizedImageShowingActivity.ARGS_IMAGE_URL, DUMMY_IMAGE_URL);
intent.putExtra(TwitterizedImageShowingActivity.ARGS_TRANSITION_NAME,
        transitionName);

ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
        MainActivity.this, imageView, transitionName);

ActivityCompat.startActivity(MainActivity.this, intent, options.toBundle());
  • Passing the showing image's bitmap:
String transitionName = ViewCompat.getTransitionName(imageView);
Intent intent = new Intent(context, TwitterizedImageShowingActivity.class);
intent.putExtra(TwitterizedImageShowingActivity.ARGS_IMAGE_BITMAP, bitmap);
intent.putExtra(TwitterizedImageShowingActivity.ARGS_TRANSITION_NAME,
        transitionName);

ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
        MainActivity.this, imageView, transitionName);

ActivityCompat.startActivity(MainActivity.this, intent, options.toBundle());

More

  • Attach the navigation by given the Menu resource ID.
intent.putExtra(TwitterizedImageShowingActivity.ARGS_BOTTOM_MENU_RES_ID,
                        R.menu.navigation);

Notice

This library is using Google Android Support Library and the version is 26.0.0. Please check it out your build environment that should be compatible with this version. You may need to add Google's maven repository in your build.gradle And, using PhotoView at the moment it is needed to add one more maven repository,

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

For more detail please refer to Support Library Setup

Sample

Sample screenshot1

License

This library is licensed under the terms in the file named "LICENSE" for more detail.

About

It's an Android View that can display image looking like Twitter's image display

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages