最近很长一段时间没有更新博客了实在是比较忙最近需要使用一个功能:选择本机相册或者拍照返回图片显示到九宫格中,并且可以点击九宫格每一张放大查看,滑动等功能!
在网上也看到一些大神写的演示和第三方库,不过发现很多都不完整,有的只是实现相册选择,没有实现拍照功能;有的实现了相册和拍照功能又没有实现点击放大查看滑动功能;所以我就跟据那些演示完善了一下,实现既能相册选择,拍照选择,点击每张图片又能放大查看现在来看看怎么实现的!
来看看效果图吧!
使用到的依赖库是
compile 'me.iwf.photopicker:PhotoPicker:0.1.8'
来看看首页的布局:activity_main.xml中中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.an.myphotodemo.MainActivity">
<com.an.myphotodemo.NoScrollGridView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/view_gad"
android:layout_marginBottom="10dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
android:numColumns="3"
android:scrollbars="none"
android:verticalSpacing="3dp"
android:id="@+id/recycler_view"/>
</LinearLayout>
NoScrollGridView是自定义的一个ScrollGridView
public class NoScrollGridView extends GridView {
public NoScrollGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NoScrollGridView(Context context) {
super(context);
}
public