【Android 控件使用及源码解析】 GridView规则显示图片仿微信朋友圈发图片
<com.view.SquareLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical" ><ImageViewandroid:id="@+id/item_grida_image"android:layout_width="match_parent"android:layout_height="match_parent"android:scaleType="fitXY"android:layout_margin="@dimen/tinyest_space"></ImageView>
</com.view.SquareLayout>
noScrollgridview = (GridView) findViewById(R.id.noScrollgridview);noScrollgridview.setNumColumns(3); //默认设置在3列图片//上传成功传值给adapterpicAdapter = new PictureAdapter(this, 1, appItem_file);noScrollgridview.setAdapter(picAdapter);
//根据图片数量设置图片的列int size = appItemFile.getFiles().split(",").length;if (size==1){noScrollgridview.setNumColumns(1);}else if (size==2){noScrollgridview.setNumColumns(2);}else if (size>2){noScrollgridview.setNumColumns(3);}picAdapter.notifyDataSetChanged();
/*** 方形布局*/
public class SquareLayout extends RelativeLayout {public SquareLayout(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);}public SquareLayout(Context context, AttributeSet attrs) {super(context, attrs);}public SquareLayout(Context context) {super(context);}@SuppressWarnings("unused")@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {// For simple implementation, or internal size is always 0.// We depend on the container to specify the layout size of// our view. We can't really know what it is since we will be// adding and removing different arbitrary views and do not// want the layout to change as this happens.setMeasuredDimension(getDefaultSize(0, widthMeasureSpec),getDefaultSize(0, heightMeasureSpec));// Children are just made to fill our space.int childWidthSize = getMeasuredWidth();int childHeightSize = getMeasuredHeight();// 高度和宽度一样heightMeasureSpec = widthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY);super.onMeasure(widthMeasureSpec, heightMeasureSpec);}
}
【Android 控件使用及源码解析】 GridView规则显示图片仿微信朋友圈发图片相关推荐
- Android仿微信朋友圈发图片和文字
Android仿微信朋友圈发图片和文字的一个开源项目,其在github上的项目主页是:https://github.com/zhangphil/FangWeiXinPengYouQuanFaTuPia ...
- android从九宫格全屏预览,仿微信朋友圈展示图片的九宫格图片展示控件,支持点击图片全屏预览大图...
AssNineGridView 仿微信朋友圈展示图片的九宫格图片展示控件,支持点击图片全屏预览大图(可自定义). 写在前面 这是一个九宫格控件,本来是很久之前就写好了,现在才开源出来,也是看了很多优秀 ...
- Android 实现仿微信朋友圈九宫格图片+NineGridView+ImageWatcher(图片查看:1.预览,2.拖动,3.放大,4.左右滑动,5.长按保存到手机)的功能
一.测试 实现: 二.添加依赖包: implementation 'androidx.appcompat:appcompat:1.1.0'implementation 'androidx.recycl ...
- Android 仿微信朋友圈添加图片
github地址(欢迎下载Demo) https://github.com/zhouxu88/WXCircleAddPic 老习惯,先上图,着急用的朋友,直接带走Demo,先拿来用吧,毕竟老板催的紧, ...
- Android 仿微信朋友圈发表图片拖拽和删除功能
朋友圈实现原理 我们使用 Android Device Monitor 来分析朋友圈发布图片的界面实现原理.如果需要分析其他应用的界面实现也是采用这种方法哦. 打开 Android Device Mo ...
- Android简易图片管理器,一个简单仿微信朋友圈的图片查看器 PhotoViewer
PhotoViewer 该图片查看器是模仿微信朋友圈查看图片编写 allprojects { repositories { ... maven { url 'https://jitpack.io' } ...
- android仿空间照片查看器,PhotoViewer 一个简单仿微信朋友圈的图片查看器
该图片查看器是模仿微信朋友圈查看图片编写 allprojects { repositories { ... maven { url 'https://jitpack.io' } } } lastRel ...
- iOS粒子特效、仿微信朋友圈、转场动画、抢红包动画等源码
iOS精选源码 viewController 之间的转场动画 swift版 视频添加水印及粒子特效 小红点(消息推送提醒)完整解决方案 仿微信朋友圈–CircleOfFriendsDisplay 图片 ...
- Android Glide 3.7.0 源码解析(八) , RecyclableBufferedInputStream 的 mark/reset 实现
个人博客传送门 一.mark / reset 的作用 Android Glide 3.7.0 源码解析(七) , 细说图形变换和解码有提到过RecyclableBufferedInputStream ...
最新文章
- ubuntu下wireshark添加root权限
- asp.net中上传文件实例
- 洛谷1231 教辅的组成
- HEVC流媒体服务器被过度炒作的5个原因
- 关系数据可视化gephi
- 学考语言成绩c对高考有影响吗_三大影响!考生务必上心,最近正在进行的学考对升学很重要...
- c语言单链表_突破C语言难点之单链表?一绘图即可
- 华为云GuassDB(for Redis)发布全新版本推出:Lua脚本和SSL连接加密
- shell编程入门步步高(二、基础概念)
- QT中文乱码的解决方法,一劳永股的解决方法,如下
- java mybatis 事务,单独的使用mybatis 如何来管理事务
- 步进电机控制(PLC)
- 分布式机器学习(下)-联邦学习
- 重装系统后计算机无法启动,重装系统后电脑为什么启动不了?云骑士告诉你怎么办?...
- C语言用随机函数做猜拳游戏,c语言猜拳游戏
- UE4使用时间轴制作简单开关门
- 中北大学计算机研究生学院,【计算机考研】院校信息-中北大学
- gcc: internal compiler error: Killed (program cc1plus)
- 全球顶尖大学已将区块链加入其课程
- 1.3 万亿条数据查询,如何做到毫秒级响应?