(转)Android控件

来源:互联网 发布:stm32跑linux 编辑:程序博客网 时间:2024/06/03 12:56

原地址:http://blog.csdn.net/lyz_zyx/article/details/52276384


ViewGroup

ViewGroup类派生于View类,它是一种可以包含其他视图特殊的布局和视图的容器。它也定义了viewgroup.layoutparams类作为基类的布局参数。子类有:LinearLayout、RelativeLayout,等。

在XM布局中常用的属性:

属性说明addStatesFromChildren定义布局是否应用子布局的背景alwaysDrawnWithCache定义子布局是否应用绘图的高速缓存animateLayoutChanges布局改变时是否有动画效果animationCache定义子布局也有动画效果clipChildren定义子布局是否一定要在限定的区域内clipToPadding定义布局间是否有间距descendantFocusability控制子布局焦点获取方式 常用于listView的item中包含多个控件 点击无效,值:beforeDescendants、afterDescendants、blocksDescendantslayoutAnimation定义布局显示时候的动画layoutMode布局模式,值:clipBounds、opticalBoundspersistentDrawingCache定义绘图的高速缓存的持久性splitMotionEvents定义布局是否传递touch事件到子布局

ViewGroup.LayoutParams

LayoutParams类用于父视图和子视图之间布局的属性信息,它封装了Layout的位置、高、宽等信息。描述宽高可以设置成三种值: 
1、match_parent,即填满(和父容器一样大小) 
2、wrap_content 根据内容大小决定 
3、一个确定的值

它的子类有: 
AbsListView.LayoutParams, AbsoluteLayout.LayoutParams, Gallery.LayoutParams, ViewGroup.MarginLayoutParams, ViewPager.LayoutParams, WindowManager.LayoutParams

属性说明layout_height指定视图的基本高度layout_width指定视图的基本宽度

ViewGroup.MarginLayoutParams

MarginLayoutParams类派生于LayoutParams类,用于每个子控件的边缘布局信息 。

属性说明layout_marginBottom指定底边额外的空间layout_marginEnd指定离结束位置额外的空间layout_marginLeft指定左边额外的空间layout_marginRight指定右边额外的空间layout_marginStart指定离开始位置额外的空间layout_marginTop指定顶边额外的空间
0 0
原创粉丝点击