第六节--LinearLayout布局的介绍和应用

来源:互联网 发布:电路仿真软件中文版 编辑:程序博客网 时间:2024/04/30 01:05

View:

LinearLayout:

java.lang.Object   ↳android.view.View    ↳android.view.ViewGroup     ↳android.widget.LinearLayout


原意

A Layout that arranges its children in a single column or a single row. The direction of the row can be set by calling setOrientation(). You can also specify gravity, which specifies the alignment of all the child elements by calling setGravity() or specify that specific children grow to fill up any remaining space in the layout by setting the weight member of LinearLayout.LayoutParams. The default orientation is horizontal.

译文

一个布局是对在行或列方向的子控件的安排。行的方向我们可以通过调用setOrientation()方法来设置。也可以通过指定它的gravitgy,通过调用setGravity()方法或指定子控件的空间填充来指定子控件元素的排列方向。缺省状态为水平方向。


 

 

XML属性

     android:id : 为控件指定相应的ID
     android:text: 指定控件当中显示的文字    

     android:grivity: 指定控件的基本位置,比如说居中,居右等位置
     android:textSize:指定控件当中字体的大小
     android:background: 使用drawable指定该控件所使用的背景色,RGB命名法
     android:width: 指定控件的宽度
     android:height: 指定控件的高度
     android:padding* : 指定控件的内边距,也就是说控件当中的内容
     android:sigleLine: 如果设置为真的话,则将控件的内容在同一行当中进行显示
     layout_weight: 用于给一个线性布局中的诸多视图的重要度赋值
     android:layout_gravity: 表示按钮在界面上的位置
     android:gravity : 表示button上的字在button上的位置
     android:visibility: 控制视图控件的可见性
     ndroid:baselineAligned:是否允许用户调整它内容的基线

 


 

 

a.lang.Object   ↳android.view.View

 

 


 

原意:

This class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.). The ViewGroup subclass is the base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.

译文:

这个类代表了用户界面组件的基本构造块。一个View在屏幕上占据一个矩形区域,并绘制和事件处理工作。View是控件的基本类它是用来创建交互式UI组件(按钮,文本框等)的。ViewGroup的基类布局的子类,它是一种无形的容器,可以保留其它控件视图和布局属性。

 


 

ViewGroup:

java.lang.Object   ↳android.view.View    ↳android.view.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.

译文

一个ViewGroupis一个能包含其它View的视图,它是一个能包含布局容器的基类布局


演示效果:

原创粉丝点击