1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > 九宫格图片上传可展示 可删除 可添加功能

九宫格图片上传可展示 可删除 可添加功能

时间:2022-05-29 07:38:03

相关推荐

九宫格图片上传可展示 可删除 可添加功能

仿照微信九宫格上传图片,也可以只展示图片

九宫格图片展示地址

先看效果

项目引入

通过gradle引入

implementation 'com.llayjun:ninepic:1.0.0'

或者直接将类拷贝到项目中,源码见底部

属性项目中使用

xml代码:

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="仅仅图片展示"android:textSize="10pt" /><com.example.ninepiclibrary.SelectImageViewandroid:id="@+id/show_image"android:layout_width="wrap_content"android:layout_height="wrap_content"app:h_space="3pt"app:is_edit="false"app:line_num="3"app:max_num="9"app:v_space="3pt"></com.example.ninepiclibrary.SelectImageView><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="可新增删除"android:textSize="10pt" /><com.example.ninepiclibrary.SelectImageViewandroid:id="@+id/select_image"android:layout_width="wrap_content"android:layout_height="wrap_content"app:add_image="@mipmap/ic_publish_add_image"app:circle_radius="8dp"app:h_space="3dp"app:is_edit="true"app:line_num="3"app:max_num="9"app:v_space="3dp"></com.example.ninepiclibrary.SelectImageView>

java代码:

// 图片展示val showList = ArrayList<String>()showList.add("/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2583035764,1571388243&fm=26&gp=0.jpg")showList.add("/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3363295869,2467511306&fm=26&gp=0.jpg")showList.add("/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3791918726,2864900975&fm=26&gp=0.jpg")showList.add("/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2583035764,1571388243&fm=26&gp=0.jpg")showList.add("/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3363295869,2467511306&fm=26&gp=0.jpg")showList.add("/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3791918726,2864900975&fm=26&gp=0.jpg")showList.add("/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2583035764,1571388243&fm=26&gp=0.jpg")showList.add("/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3791918726,2864900975&fm=26&gp=0.jpg")showList.add("/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2583035764,1571388243&fm=26&gp=0.jpg")show_image.addPhoto(showList)show_image.setOnImageClickListener { position, filePath ->Toast.makeText(this, "点击图片${position}", Toast.LENGTH_LONG).show()}// 可增加删除的val initList = ArrayList<String>()initList.add("/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2583035764,1571388243&fm=26&gp=0.jpg")initList.add("/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3363295869,2467511306&fm=26&gp=0.jpg")initList.add("/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3791918726,2864900975&fm=26&gp=0.jpg")select_image.addPhoto(initList)select_image.setOnAddClickListener {Toast.makeText(this, "选择照片", Toast.LENGTH_LONG).show()val list = ArrayList<String>()list.add("/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3791918726,2864900975&fm=26&gp=0.jpg")select_image.addPhoto(list)}select_image.setOnImageClickListener { position, filePath ->Toast.makeText(this, "点击图片${position}", Toast.LENGTH_LONG).show()}

源代码地址

九宫格图片展示地址

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。