继承ViewGroup
来源:互联网 发布:许晴 王雪冰 知乎 编辑:程序博客网 时间:2024/05/16 17:46
package wld.bawei.com.myonemoni2.view;import android.content.Context;import android.util.AttributeSet;import android.view.View;import android.view.ViewGroup;/** * Created by 大金鑫 on 2017/12/3. */public class Liushibuju extends ViewGroup { public Liushibuju(Context context) { this(context,null); } public Liushibuju(Context context, AttributeSet attrs) { this(context, attrs,0); } public Liushibuju(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); } @Override protected void onLayout(boolean b, int i, int i1, int i2, int i3) { int width=0; int height=0; int childCount = getChildCount(); for(int k=0;k<childCount;k++){ View childAt = getChildAt(k); int measuredWidth = childAt.getMeasuredWidth(); int measuredHeight = childAt.getMeasuredHeight(); childAt.layout(width,height,measuredWidth+width,measuredHeight+height); width+=measuredWidth; height+=measuredHeight; } }}
阅读全文
0 0
- 继承viewgroup
- 继承ViewGroup
- Android 继承ViewGroup研究
- 继承ViewGroup研究
- 继承ViewGroup研究
- 自定义View继承ViewGroup
- 自定义View继承ViewGroup
- Android继承ViewGroup研究(1)
- Android 继承ViewGroup研究(2)
- Android 继承ViewGroup研究(3)
- 继承ViewGroup的自定义类
- 继承ViewGroup的自定义类
- 常用类继承自ViewGroup的写法
- 日积月累:继承ViewGroup不调用onDraw()方法
- LayoutParams继承于Android.View.ViewGroup.LayoutParams.
- 继承ViewGroup重写onMeasure方法的详解
- 继承ViewGroup需要重写的方法
- 自定义view继承viewgroup的解释
- 如何努力才能成为编程高手
- 十二月目标
- Hive的数据模型之桶表
- Java转Python入门之运算与循环
- MongoDB的使用
- 继承ViewGroup
- LeetCode 477. Total Hamming Distance
- SAP Fiori For iOS
- 自定义view实现无线轮播
- webview
- ShoneSharp语言(S#)的设计和使用介绍系列(4)— 入门概述
- 状压dp Survival
- 通过当前时间获取当前所在周的7天的时间
- Hive的数据模型之视图