附加是我嘗試在android佈局中使用的佈局類型。我有兩個彼此相鄰的文本視圖,每個視圖都水平放置一半。然後我在下面的空間中有其他文字視圖。在相對佈局中使用權重並排顯示文本視圖
我打算使用相對佈局,但後來我無法將它們中的兩個並排放置並佔據相同的空間量。有人可以幫我解決這個問題嗎?
附加是我嘗試在android佈局中使用的佈局類型。我有兩個彼此相鄰的文本視圖,每個視圖都水平放置一半。然後我在下面的空間中有其他文字視圖。在相對佈局中使用權重並排顯示文本視圖
我打算使用相對佈局,但後來我無法將它們中的兩個並排放置並佔據相同的空間量。有人可以幫我解決這個問題嗎?
嘗試這種方式
<?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="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="hello " />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="hello" />
</LinearLayout>
<TextView
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="hello " />
<TextView
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="hello" />
</LinearLayout>
以及如何添加垂直放置在下面的其他兩個文本視圖。 – Kraken
檢查我更新的答案 –
可以嘗試下面的邏輯。
LinearLayout
- Vertical Orientation
- LinearLayout
-HorizontalOrientation
-weightSum=2
-TextView1 with weight=1
-TextView2 with weight = 1
-TextView 3
-TextView 4
然後對於兩個文本視圖使用線性佈局,權重= 2和權重= 1 –
相對佈局內的線性佈局? – Kraken
不只是線性佈局。 –