我们随便打开一个app,展现在我们眼前的界面,都是由布局或者说包含控件的布局展示
布局
布局是把它包含的控件怎么排布。常用的布局有LinearLayout (线性布局)、RelativeLayout(相对布局)、.FrameLayout(框架布局)。当然还有其他的布局,我在开发中都很少用到。如果是入门了解这3个布局就可以了。
LinearLayout (线性布局)
线性布局是里面的排布有规律,不是横向排布,就是纵向排布。
横向排布
在布局内设置
android:orientation="horizontal"
下面的图是我设置了4个控件的横向线性布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:t