码迷,mamicode.com
首页 > 移动开发 > 详细

android 瀑布流 AndroidStaggeredGrid

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

标签:android   瀑布流   androidstaggeredgrid   

开源项目: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

标签:android   瀑布流   androidstaggeredgrid   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!