线性布局
.xml文件代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第一个文本"
android:textColor="#FF00"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第二个文本"
android:textColor="#FF00FF"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="第三个文本"
android:textColor="#00FF00"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"
android:textColor="#F00F"/>
</LinearLayout>
此行代码规定水平还是垂直布局:
垂直:
水平:
桌面布局
.xml文件代码如下:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent