GithubHelp home page GithubHelp logo

dragmorescrollview's Introduction

DragMoreScrollView

一种浏览图片的交互效果实现,类似iOS相册

使用方法:

<com.crazypumpkin.library.DragMoreScrollView 
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:photoReservedHeight="150dp"
    app:fullAnimationDuration="250"
    android:background="#000000">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.github.chrisbanes.photoview.PhotoView
            android:id="@+id/iv_detail"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitCenter"/>

        <FrameLayout
            android:id="@+id/fl_detail_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/ll_detail_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
                
                <!-- 详情内容(请按照以上的层级结构,detail_container 只能有一个子View) -->
                
            </LinearLayout>
        </FrameLayout>

    </FrameLayout>
</com.crazypumpkin.library.DragMoreScrollView>

代码设置:

mIvDetail.setOnScaleChangeListener(new OnScaleChangedListener() {
            @Override
            public void onScaleChange(float scaleFactor, float focusX, float focusY) {
                //当图片正在放大浏览的时候,禁用ScrollView
                String scale = mScaleFormat.format(mIvDetail.getScale());
                if (Float.parseFloat(scale) > 1) {
                    mDragMoreScrollView.setEnabled(false);
                } else {
                    mDragMoreScrollView.setEnabled(true);
                }
            }
        });
mDragMoreScrollView.setRatio(1f);//设置图片宽高比
mDragMoreScrollView.setExitZoomRect(new Rect());//设置缩略图的所占区域
//处于详情模式时应禁用图片缩放功能,在退出的时候finish Activity
mDragMoreScrollView.setOnStatusChangeListener(new DragMoreScrollView.OnStatusChangeListener() {
    @Override
    public void onDetailMode() {
        mIvDetail.setZoomable(false);
    }

    @Override
    public void onPhotoMode() {
        mIvDetail.setZoomable(true);
    }

    @Override
    public void onExit() {
        finish();
    }
});

dragmorescrollview's People

Contributors

jerryion avatar

Watchers

MAY3AM 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.