Android学习笔记(8):ViewGroup类

A ViewGroup is a special view that can contain other views (called children.) 

The view group is the base class for layouts and views containers. 

This class also defines the ViewGroup.LayoutParams class which serves as the base class for layouts parameters.

 

ViewGroupView的一个子类。本身是一个抽象类,UI控件都是由ViewViewGroup派生而来的,当中ViewGroup的子类通常作为容器,或者说是布局管理器。

容器内子组件的分布依赖ViewGroup.LayoutParamsViewGroup.MarginLayoutParams。这是ViewGroup的两个内部类。

 

ViewGroup.LayoutParams所支持的XML属性:

android:layout_height——指定该子组件的布局高度

android:layout_width——指定该子组件的布局宽度

这两个属性的可选属性值例如以下:

(1). fill_parent——子组件宽度、高度与父容器同样

(2). match_parent——子组件宽度、高度与父容器同样(与上同样,推荐使用)

(3). wrap_content——子组件的大小刚好能包裹它的内容

 

Android组件的大小除了受实际宽度、高度的控制,还受其布局宽度和高度控制,且布局宽度、高度其主要作用。

 

ViewGroup.MarginLayoutParams所支持的XML属性:

Attribute Name

Related Method

Description

android:layout_marginBottom

setMargins(int,int,int,int)

设置该子组件下边的页边距

android:layout_marginEnd

setMarginEnd(int)

设置该子组件距离终边的页边距

android:layout_marginLeft

setMargins(int,int,int,int)

设置该子组件左边的页边距

android:layout_marginRight

setMargins(int,int,int,int)

设置该子组件右边的页边距

android:layout_marginStart

setMarginStart(int)

设置该子组件距离起始边的页边距

android:layout_marginTop

setMargins(int,int,int,int)

设置该子组件上边的页边距

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值