本文实例讲述了Android编程重写ViewGroup实现卡片布局的方法。分享给大家供大家参考,具体如下:
实现效果如图:
实现思路
1. 重写onMeasure(int widthMeasureSpec, int heightMeasureSpec)设置每个子View的大小
2. 重写onLayout(boolean changed, int l, int t, int r, int b) 设置每个子View的位置
第一步:新建FlowLayout继承ViewGroup
package com.rong.activity;
import android.content.Context;