首页 > 移动平台 > 详细

android 瀑布流 AndroidStaggeredGrid

时间:2014-10-31 19:13:16      阅读:433      评论:0      收藏:0      [点我收藏+]

开源项目:https://github.com/etsy/AndroidStaggeredGrid

分享一下我用过之后,觉得最关键的地方。
在给出的demo中有一个集合,记录每个位置的HeightRatio。设置Dyn/amicHeightTextView和DynamicHeightImageView的HeightRatio来控制显示的高度。
比如在DynamicHeightImageView中有一段代码来设置imageview的显示高度:
     

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        if (mHeightRatio > 0.0) {

            // set the image views size

            int width = MeasureSpec.getSize(widthMeasureSpec);

            int height = (int) (width * mHeightRatio);

            setMeasuredDimension(width, height);

        }

        else {

            super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        }

    }  

了解这几点之后,就能够显示出高低不一样的图片效果

本文出自 “我爱我家” 博客,请务必保留此出处http://hngah.blog.51cto.com/8008803/1570483

android 瀑布流 AndroidStaggeredGrid

原文:http://hngah.blog.51cto.com/8008803/1570483

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!