LinearLayout 線性布局
關鍵詞:LinearLayout 線性布局 orientation 方向 width/height 寬/高 weight 權重
match_parent/wrap_content 充滿/適應 horizontal/vertical 水平/垂直
<?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="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
</LinearLayout>
</LinearLayout>

動手修改權重和方向,前后對比了解:

修改方向同時要修改相應寬高,依然是1:1
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></LinearLayout>
<LinearLayout
android:id="@+id/linearlayout" //設定id
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></LinearLayout>
</LinearLayout>
最常用布局
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/225382.html
標籤:其他
下一篇:微信小程式分頁功能實作
