我有5個圖像應該水平放置在一個線性佈局中,並且應該以第三個圖像位於屏幕中心的方式進行合理的處理。所有的圖像具有相同的寬度和高度。如何在android線性佈局水平方向上對齊項目對齊?
即圖像之間的填充應該動態調整。
感謝
我有5個圖像應該水平放置在一個線性佈局中,並且應該以第三個圖像位於屏幕中心的方式進行合理的處理。所有的圖像具有相同的寬度和高度。如何在android線性佈局水平方向上對齊項目對齊?
即圖像之間的填充應該動態調整。
感謝
試試這個:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ff5678" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ff5678" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ff5678" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ff5678" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ff5678" />
</LinearLayout>
beetwen each ImageView
加空View
使用參數:android:layout_width="0dp"
android:layout_weight="1"
感謝它的工作 – hybrid
我會建議你在這種情況下要使用相對佈局。 – Bhargav