WeChatImg-使用kotlin写一个仿微信点击图片浏览的效果.zip

上传者: 38743506 | 上传时间: 2021-08-03 12:43:24 | 文件大小: 140KB | 文件类型: ZIP
最近在学习kotlin,项目中正好用到了图片浏览,就用kotlin放照微信的做了一个,效果如下:大概就是这么个效果,图片从小到大的一个效果,然后滑动切换图片,点击后会返回对应图片的位置,其实比较容易,用到的是ActivityOptions,一个activity的转场动画,下面说一下怎么实现。github地址点这里关于kotlin的配置就不过多说了,网上好多教程(最近kotlin好火)布局就是一个recyclerviewmainactivity代码:可以看到就一个初始化布局管理器和设置适配器的代码没什么了(你说没看到初始化控件?看看这篇文章)到这里之前都很好理解,关键就是adapter和点击图片跳转的代码在API 21以后,我们可以使用内置的Activity切换动画。但是这样也就意味着只能兼容5.0之后的系统,ActivityOptions是一个静态类,它提供了为数不多的几种方法,我们正是用其中的makeSceneTransitionAnimation(Activity activity,Pair… sharedElements)来完成了这个效果,有兴趣的小伙伴移步至这里,先来说下传递的两个参数,第一个activity不用说,第二个pair,View是你开始动画的view对象,string是他的动画名要和结束动画的view名一致才可以,到这里应该可以理解,我们在创建适配器的时候给每个imageview起了一个transitionname当我们跳转至查看大图界面给当前的viewpage赋值相同的名称便能完成动画,然后在我们滑动时更改viewpage的transitionname为对应图片的transitionname这样在点击图片的时候就会显示对应图片的下标。

文件下载

资源详情

[{"title":"( 41 个子文件 140KB ) WeChatImg-使用kotlin写一个仿微信点击图片浏览的效果.zip","children":[{"title":"WeChatImg-master","children":[{"title":"gradlew <span style='color:#111;'> 4.85KB </span>","children":null,"spread":false},{"title":"settings.gradle <span style='color:#111;'> 15B </span>","children":null,"spread":false},{"title":".idea","children":[{"title":"runConfigurations.xml <span style='color:#111;'> 564B </span>","children":null,"spread":false},{"title":"misc.xml <span style='color:#111;'> 1.59KB </span>","children":null,"spread":false},{"title":"gradle.xml <span style='color:#111;'> 626B </span>","children":null,"spread":false},{"title":"modules.xml <span style='color:#111;'> 355B </span>","children":null,"spread":false}],"spread":true},{"title":"gradle","children":[{"title":"wrapper","children":[{"title":"gradle-wrapper.properties <span style='color:#111;'> 235B </span>","children":null,"spread":false},{"title":"gradle-wrapper.jar <span style='color:#111;'> 52.38KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"gradlew.bat <span style='color:#111;'> 2.26KB </span>","children":null,"spread":false},{"title":"gradle.properties <span style='color:#111;'> 730B </span>","children":null,"spread":false},{"title":".gitignore <span style='color:#111;'> 118B </span>","children":null,"spread":false},{"title":"app","children":[{"title":"src","children":[{"title":"androidTest","children":[{"title":"java","children":[{"title":"com","children":[{"title":"img","children":[{"title":"wechatimg","children":[{"title":"ExampleInstrumentedTest.kt <span style='color:#111;'> 636B </span>","children":null,"spread":false}],"spread":false}],"spread":true}],"spread":true}],"spread":true}],"spread":true},{"title":"test","children":[{"title":"java","children":[{"title":"com","children":[{"title":"img","children":[{"title":"wechatimg","children":[{"title":"ExampleUnitTest.kt <span style='color:#111;'> 342B </span>","children":null,"spread":false}],"spread":false}],"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":"main","children":[{"title":"AndroidManifest.xml <span style='color:#111;'> 839B </span>","children":null,"spread":false},{"title":"res","children":[{"title":"mipmap-hdpi","children":[{"title":"ic_launcher.png <span style='color:#111;'> 3.28KB </span>","children":null,"spread":false},{"title":"ic_launcher_round.png <span style='color:#111;'> 4.96KB </span>","children":null,"spread":false}],"spread":false},{"title":"mipmap-xxxhdpi","children":[{"title":"ic_launcher.png <span style='color:#111;'> 9.22KB </span>","children":null,"spread":false},{"title":"ic_launcher_round.png <span style='color:#111;'> 15.73KB </span>","children":null,"spread":false}],"spread":false},{"title":"mipmap-xhdpi","children":[{"title":"ic_launcher.png <span style='color:#111;'> 4.54KB </span>","children":null,"spread":false},{"title":"ic_launcher_round.png <span style='color:#111;'> 7.21KB </span>","children":null,"spread":false}],"spread":false},{"title":"mipmap-mdpi","children":[{"title":"ic_launcher.png <span style='color:#111;'> 2.33KB </span>","children":null,"spread":false},{"title":"ic_launcher_round.png <span style='color:#111;'> 3.10KB </span>","children":null,"spread":false}],"spread":false},{"title":"layout","children":[{"title":"activity_image.xml <span style='color:#111;'> 555B </span>","children":null,"spread":false},{"title":"item_img.xml <span style='color:#111;'> 542B </span>","children":null,"spread":false},{"title":"item_pic_show.xml <span style='color:#111;'> 422B </span>","children":null,"spread":false},{"title":"activity_main.xml <span style='color:#111;'> 484B </span>","children":null,"spread":false}],"spread":false},{"title":"values","children":[{"title":"colors.xml <span style='color:#111;'> 208B </span>","children":null,"spread":false},{"title":"arrays.xml <span style='color:#111;'> 774B </span>","children":null,"spread":false},{"title":"strings.xml <span style='color:#111;'> 73B </span>","children":null,"spread":false},{"title":"styles.xml <span style='color:#111;'> 383B </span>","children":null,"spread":false}],"spread":false},{"title":"mipmap-xxhdpi","children":[{"title":"ic_launcher.png <span style='color:#111;'> 6.84KB </span>","children":null,"spread":false},{"title":"ic_launcher_round.png <span style='color:#111;'> 11.27KB </span>","children":null,"spread":false}],"spread":false}],"spread":false},{"title":"java","children":[{"title":"com","children":[{"title":"img","children":[{"title":"wechatimg","children":[{"title":"view","children":[{"title":"PhotoViewPager.kt <span style='color:#111;'> 857B </span>","children":null,"spread":false}],"spread":false},{"title":"MainActivity.kt <span style='color:#111;'> 664B </span>","children":null,"spread":false},{"title":"adapter","children":[{"title":"popAdapter.kt <span style='color:#111;'> 1.40KB </span>","children":null,"spread":false},{"title":"imgAdapter.kt <span style='color:#111;'> 1.40KB </span>","children":null,"spread":false}],"spread":false},{"title":"ImageActivity.kt <span style='color:#111;'> 2.24KB </span>","children":null,"spread":false}],"spread":false}],"spread":false}],"spread":false}],"spread":false}],"spread":true}],"spread":true},{"title":".gitignore <span style='color:#111;'> 7B </span>","children":null,"spread":false},{"title":"build.gradle <span style='color:#111;'> 1.30KB </span>","children":null,"spread":false},{"title":"proguard-rules.pro <span style='color:#111;'> 934B </span>","children":null,"spread":false}],"spread":true},{"title":"build.gradle <span style='color:#111;'> 718B </span>","children":null,"spread":false}],"spread":true}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明