使用的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
小奋斗文章
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~