android 照片点击查看,Android PhotoView点击放大图片效果

使用的PhotoView是这个版本的,比较小巧,很好用,比github上另一个版本的瘦身很多:https://github.com/bm-x/PhotoView

基本测试代码如下:import java.util.ArrayList;

import android.content.Context;

import android.os.Bundle;

import android.support.v7.widget.DefaultItemAnimator;

import android.support.v7.widget.GridLayoutManager;

import android.support.v7.widget.RecyclerView;

import android.view.View;

import com.widget.common.recycler.BaseRecyclerAdapter;

import com.widget.common.recycler.SpacesItemDecoration;

import com.widget.common.recycler.ViewHolder;

import com.widget.photoView.Info;

import com.widget.photoView.PhotoView;

/**

* 测试PhotoView代码

* @author pythoner

*

*/

public class GridImageActivity extends BaseActivity {

private Context context;

private RecyclerView recyclerView;

private BaseRecyclerAdapter adapter;

private PhotoView photoView;//变换后的图片

private PhotoView curPhotoView;//源图片

private Info mRectF;//源图片位置信息

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_grid_image);

context = this;

initActionBar("图片列表", null, null);

initViews();

}

@Override

public void initViews() {

// TODO Auto-generated method stub

initRecyclerView();

photoView=(PhotoView)findViewById(R.id.photoView);

photoView.enable();// 需要启动缩放需要手动开启

photoView.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

// 从自身位置变换到源图片的位置

photoView.animaTo(mRectF, new Runnable() {

@Override

public void run() {

photoView.setVisibility(View.GONE);

curPhotoView.setVisibility(View.VISIBLE);

}

});

}

});

}

private void initRecyclerView() {

recyclerView = (RecyclerView) findViewById(R.id.recyclerView);

// recyclerView.addItemDecoration(new DividerGridItemDecoration(this));

recyclerView.addItemDecoration(new SpacesItemDecoration(16));

recyclerView.setItemAnimator(new DefaultItemAnimator());

GridLayoutManager manager = new GridLayoutManager(this, 3);

recyclerView.setLayoutManager(manager);

final ArrayList list = new ArrayList();

list.add(R.drawable.bg_login);

list.add(R.drawable.chat_bg_default);

list.add(R.drawable.bg_diagonal);

list.add(R.drawable.bg_diagonal);

list.add(R.drawable.chat_bg_default);

list.add(R.drawable.bg_login);

list.add(R.drawable.bg_login);

list.add(R.drawable.chat_bg_default);

list.add(R.drawable.bg_diagonal);

list.add(R.drawable.bg_diagonal);

list.add(R.drawable.chat_bg_default);

list.add(R.drawable.bg_login);

recyclerView.setAdapter(adapter = new BaseRecyclerAdapter(

context, list) {

@Override

public int onCreateViewLayoutID(int viewType) {

// TODO Auto-generated method stub

return R.layout.item_grid_image;

}

@Override

public void onBindViewHolder(ViewHolder holder, final Integer item,

final int position) {

// TODO Auto-generated method stub

final PhotoView item_0=holder.getView(R.id.item_0);

item_0.disenable();

item_0.setImageResource(item);

item_0.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

curPhotoView=item_0;

item_0.setVisibility(View.GONE);

photoView.setVisibility(View.VISIBLE);

photoView.setImageResource(item);

//获取源位置信息

mRectF = item_0.getInfo();

//从源位置变换到他本身的位置

photoView.animaFrom(mRectF);

}

});

}

});

}

@Override

public void onBackPressed() {

if (photoView.getVisibility() == View.VISIBLE) {

photoView.animaTo(mRectF, new Runnable() {

@Override

public void run() {

photoView.setVisibility(View.GONE);

curPhotoView.setVisibility(View.VISIBLE);

}

});

} else {

super.onBackPressed();

}

}

@Override

public void updateViews(Object obj) {

// TODO Auto-generated method stub

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

android:id="@+id/recyclerView"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:scrollbars="vertical" />

android:id="@+id/photoView"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@android:color/transparent"

android:scaleType="fitCenter"

android:src="@drawable/bg_login"

android:visibility="gone" />

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GridImageView网格图片控件https://github.com/A-W-C-J/GridImageView

ImageWatcher

图片查看器,为各位追求用户体验的daLao提供更优质的服务 它能够

1、点击图片时以一种无缝顺畅的动画切换到图片查看的界面,同样以一种无缝顺畅的动画退出图片查看界面

2、支持多图查看,快速翻页,双击放大,单击退出,双手缩放旋转图片

3、下拽退出查看图片的操作,以及效果是本View的最大卖点(仿微信)https://github.com/iielse/DemoProjects/tree/master/P02_ImageWatcher

仿微博、微信、qq 点击缩略图后预览高清图的组件

TransferImage 是一款模仿微博、微信、qq的高清图查看控件, 实现了在列表控件(ListView, RecycleView, GridView 等...)中 点击缩略图后播放过渡动画, 加载高清图, 加载高清图时同时显示加载进度条, 加载完成后显示高清图的一个组件。同时关闭 TransferImage 也会有对应的过渡动画.

此库若有不完善的地方, 请提 Issues, 我会尽快修复改善

支持或包含的功能:

打开和关闭 TransferImage 的过渡动画, 支持自定义

图片加载内置了一个使用 Glide 框架的图片加载器, 支持自定义

图片支持手势操作, 可缩放、双击、移动

图片加载时的进度条, 支持自定义

图片索引指示器, 支持自定义https://github.com/Hitomis/TransferImage

小奋斗文章

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PhotoView PhotoView aims to help produce an easily usable implementation of a zooming Android ImageView. Branch Develop: Build Status Branch Master: Build Status PhotoView Features Out of the box zooming, using multi-touch and double-tap. Scrolling, with smooth scrolling fling. Works perfectly when used in a scrolling parent (such as ViewPager). Allows the application to be notified when the displayed Matrix has changed. Useful for when you need to update your UI based on the current zoom/scroll position. Allows the application to be notified when the user taps on the Photo. Sample Application The sample application (the source is in the repository) has been published onto Google Play for easy access: Get it on Google Play Gradle Dependency Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ... maven { url "https://jitpack.io" } } } Then, add the library to your project build.gradle dependencies { compile 'com.github.chrisbanes:PhotoView:1.2.6' } Sample Usage There is a sample provided which shows how to use the library in a more advanced way, but for completeness here is all that is required to get PhotoView working: ImageView mImageView; PhotoViewAttacher mAttacher; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Any implementation of ImageView can be used! mImageView = (ImageView) findViewById(R.id.iv_photo); // Set the Drawable displayed Drawable bitmap = getResources().getDrawable(R.drawable.wallpaper); mImageView.setImageDrawable(bitmap); // Attach a PhotoViewAttacher, which takes care of all of the zooming functionality. // (not needed unless you are going to change the drawable later) mAttacher = new PhotoViewAttacher(mImageView); } // If you later call mImageView.setImageDrawable/setImageBitmap/setImageResource/etc then you just need to call mAttacher.update(); Issues With ViewGroups There are some ViewGroups (ones that utilize onInterceptTouchEvent) that throw exceptions when a PhotoView is placed within them, most notably ViewPager and DrawerLayout. This is a framework issue that has not been resolved. In order to prevent this exception (which typically occurs when you zoom out), take a look at HackyDrawerLayout and you can see the solution is to simply catch the exception. Any ViewGroup which uses onInterceptTouchEvent will also need to be extended and exceptions caught. Use the HackyDrawerLayout as a template of how to do so. The basic implementation is: public class HackyProblematicViewGroup extends ProblematicViewGroup { public HackyProblematicViewGroup(Context context) { super(context); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { try { return super.onInterceptTouchEvent(ev); } catch (IllegalArgumentException e) { //uncomment if you really want to see these errors //e.printStackTrace(); return false; } } } Usage with Fresco Due to the complex nature of Fresco, this library does not currently support Fresco. See this project as an alternative solution. Subsampling Support This library aims to keep the zooming implementation simple. If you are looking for an implementation that supports subsampling, check out this project Pull Requests / Contribution Development happens in develop branch of this repository, and Pull Requests should be filled against that branch. Any Pull Request against master will be rejected License Copyright 2011, 2012 Chris Banes 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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值