android studio 新建一个项目,修改XML如下
注意此项目的Activity名称为:MyLinearlayout。
<?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="vertical"
tools:context=".MyLinearlayout">
<!--orientation:方向 => vertical:竖的 ,horizontal:水平的-->
<!--margin:边缘 =>设置控件或布局先对边距-->
<!--gravity:状况=>设置控件或布局相对位置 -->