公共组件汇总

公共组件使用方法


图片选择器

<h1>图片选择器</h1> <hr /> <h2>样式展示</h2> <h3>适配器(可根据自己样式调整)</h3> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/dfee2fdc232ab1a9d9dfea4d0c2bd47b?showdoc=.jpg" alt="" /></p> <h3>图片选择</h3> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/04fa8bb13dda2185e46b6c1609de3076?showdoc=.jpg" alt="" /></p> <h3>预览图</h3> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/f28bf310c5487dc6cb8a0d98c54e6a08?showdoc=.jpg" alt="" /></p> <h2>控件代码使用及参数说明</h2> <h3>实例化</h3> <pre><code> PictureSelector.create(this) .openGallery(PictureMimeType.ofImage())// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio() .theme(themeId)// 主题样式设置 R.style.picture_QQ_style .maxSelectNum(5)// 最大图片选择数量 .minSelectNum(1)// 最小选择数量 .imageSpanCount(4)// 每行显示个数 .selectionMode(PictureConfig.MULTIPLE)// 多选 or 单选 .previewImage(true)// 是否可预览图片 .previewVideo(false)// 是否可预览视频 .enablePreviewAudio(true) // 是否可播放音频 .isCamera(true)// 是否显示拍照按钮 .isZoomAnim(true)// 图片列表点击 缩放效果 默认true .compress(true)// 是否压缩 .synOrAsy(true)//同步true或异步false 压缩 默认同步 .glideOverride(160, 160)// glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度 .selectionMedia(selectList)// 是否传入已选图片 .minimumCompressSize(100)// 小于100kb的图片不压缩 .forResult(1);//结果回调onActivityResult code</code></pre> <h3>回调处理</h3> <pre><code> protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { switch (requestCode) { case 1: // 图片选择结果回调 selectList = PictureSelector.obtainMultipleResult(data); // 例如 LocalMedia 里面返回三种path // 1.media.getPath(); 为原图path // 2.media.getCutPath();为裁剪后path,需判断media.isCut();是否为true // 3.media.getCompressPath();为压缩后path,需判断media.isCompressed();是否为true // 如果裁剪并压缩了,已取压缩路径为准,因为是先裁剪后压缩的 for (LocalMedia media : selectList) { Log.i("图片-----》", media.getPath()); } adapter.setList(selectList); adapter.notifyDataSetChanged(); break; } } }</code></pre>

页面列表

ITEM_HTML