和你一起终身学习,这里是程序员Android
经典好文推荐,通过阅读本文,您将收获以下知识点:
一、LinearLayout 线性布局
二、RelativeLayout 关系布局
三、FrameLayout 帧布局
四、TableLayout 表格布局
在Android
中,有界面存在的地方就会有布局存在,布局对于Android
来说十分重要。Android
中常用的四大布局:LinearLayout、RelativeLayout、FrameLayout、TableLayout
。
AbsoluteLayout 已经弃用,此问略过。
一、LinearLayout 线性布局
线性布局,Android
常用布局之一,主要有水平布局、垂直布局两种。线性布局 水平布局主要靠orientation
属性区分, 垂直布局:android:orientation="vertical"
,水平布局:android:orientation="horizontal"
。
1.线性布局继承关系
java.lang.Object
↳ android.view.View
↳ android.view.ViewGroup
↳ android.widget.LinearLayout
2. LinearLayout 简单例子
LinearLayout 布局例子
上述布局代码实现如下:
<LinearLayout
android:id="@+id/ll_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/holo_purple"
android:gravity="center_horizontal"
android:paddin