【Android 入門指南】系列文章目錄:https://bit.ly/3TFgCzu
Android 線上課程教學影片:https://bit.ly/433Offj
本課程學習如何使用 LinearLayout 線性佈局中的 gravity 對齊屬性。
<?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"
android:background="#e6e6e6"
android:gravity="center">
<Button
android:text="元件一"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:text="元件二"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:text="元件三"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>