Coder Social home page Coder Social logo

imagecoverflow's Introduction

ImageCoverFlow

To show Cover Flow effect on Android

ImageCoverFlow is an open source Android library that allows developers to easily create applications with a cover flow effect to show images. This library does not extend Gallery. Feel free to use it all you want in your Android apps provided that you cite this project and include the license in your app.

Note: looping mode is currently supported, non-looping mode will be supported later.

Oops! The screenshot is missing!

ImageCoverFlow is currently used in some published Android apps:

  1. ICardEnglish

How to Use:

Step One: Add CoverFlowView to your project

  1. Via XML:
<com.dolphinwang.imagecoverflow.CoverFlowView
    xmlns:imageCoverFlow="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coverflow"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"
    imageCoverFlow:coverflowGravity="center_vertical"
    imageCoverFlow:coverflowLayoutMode="wrap_content"
    imageCoverFlow:enableReflection="true"
    imageCoverFlow:reflectionGap="10dp"
    imageCoverFlow:reflectionHeight="30%"
    imageCoverFlow:reflectionShaderEnable="true"
    imageCoverFlow:visibleImage="5" />
  1. Programatically (via Java):
CoverFlowView<MyCoverFlowAdapter> mCoverFlowView =
    (CoverFlowView<MyCoverFlowAdapter>) findViewById(R.id.coverflow);

mCoverFlowView.setCoverFlowGravity(CoverFlowGravity.CENTER_VERTICAL);
mCoverFlowView.setCoverFlowLayoutMode(CoverFlowLayoutMode.WRAP_CONTENT);
mCoverFlowView.enableReflection(true);
mCoverFlowView.setReflectionHeight(30);
mCoverFlowView.setReflectionGap(20);
mCoverFlowView.enableReflectionShader(true);
mCoverFlowView.setVisibleImage(5);

TIP: If you want to support different movement speeds on different screen densities, you can use method setScreenDensity(). Otherwise CoverFlow will have a unified movement speed.


Step Two: Set an adapter, which extends CoverFlowAdapter:

MyCoverFlowAdapter adapter = new MyCoverFlowAdapter(this);
mCoverFlowView.setAdapter(adapter);

TIPS:

  • Method setAdapter() should be called after all properties of CoverFlow are settled.
  • If you want to load image dynamically, you can call method notifyDataSetChanged() when bitmaps are loaded.

Step Three: if you want to listen for the click event of the top image, you can set a CoverFlowListener to it:

mCoverFlowView.setCoverFlowListener(new CoverFlowListener<MyCoverFlowAdapter>() {
    @Override
    public void imageOnTop(CoverFlowView<MyCoverFlowAdapter> view, int position,
            float left, float top, float right,float bottom) {
        // TODO
    }

    @Override
    public void topImageClicked(CoverFlowView<MyCoverFlowAdapter> view, int position) {
        // TODO
    }
});

If you want to listen for long click events of the top image, you can set a TopImageLongClickListener to it:

mCoverFlowView
    .setTopImageLongClickListener(new CoverFlowView.TopImageLongClickListener() {
        @Override
        public void onLongClick(int position) {
            Log.e(VIEW_LOG_TAG, "top image long clicked ==> " + position);
        }
    });

Users can use method setSelection() to show a specific position at the top.


If you want to subclass CoverFlowView

  1. You can override method getCustomTransformMatrix() to make more transformations for images (there is some annotated code which shows how to make image y-axis rotation).
  2. You should never override method onLayout() to layout any of CoverFlowViewโ€™s children, because all of image will draw on the canvas directly.

Developed By:

Roy Wang ([email protected])

If you use this library, please let me know.


License:

Copyright 2013 Roy Wang

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.

imagecoverflow's People

Contributors

dolphinwang avatar

Watchers

 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.