android 自定义View 流试布局简单例子
来源:互联网 发布:淘宝图片分辨率72 编辑:程序博客网 时间:2024/06/05 06:51
public class TextView extends ViewGroup { private int size; private int widthSize; public TextView(Context context) { super(context); } public TextView(Context context, AttributeSet attrs) { super(context, attrs); } public TextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); measureChildren(widthMeasureSpec, heightMeasureSpec); widthSize = MeasureSpec.getSize(widthMeasureSpec); } @Override protected void onLayout(boolean c, int l, int t, int r, int b) { int childCount = getChildCount(); int startWidth = 5; int startheight = 0; for (int j = 0; j < childCount; j++) { View v = getChildAt(j); //设置位置 v.layout(startWidth, startheight, startWidth + v.getMeasuredWidth() + 5, startheight + v.getMeasuredHeight()); startWidth += v.getMeasuredWidth(); if (startWidth >= widthSize) { startWidth = 0; startheight += v.getMeasuredHeight() + 10; } } }}
阅读全文
0 0
- android 自定义View 流试布局简单例子
- 自定义view简单例子
- 自定义View简单小例子
- android 自定义view 流式布局
- android 自定义view实现流式布局
- Android自定义View实现流式布局
- Android-->FlowRadioGroup(流式布局RadioGroup, 自定义View的简单使用)
- android简单自定义view
- Android 简单自定义View
- 百分比布局,android自定义View。
- android 自定义View 梯形布局
- 简单自定义View流式布局实现模版
- Android中自定义View,自定义布局
- Android--View自定义—标签<流式布局>
- 自定义View流式布局
- Android自定义简单的View
- Android自定义简单的View
- Android自定义简单的View
- 天马行空地做梦,脚踏实地地做事
- 优秀的程序员是什么样的?
- Fragment 里套Fragment
- css相册代码
- 补题
- android 自定义View 流试布局简单例子
- 集合的全排列问题
- react-ts开发中获取ref节点的方法
- 无限轮播标题栏
- 机房收费系统——登录窗体
- Java Object类
- 整数划分问题
- java基础-面向对象三大特征(初学者)
- 程序3-2 开灯问题