hyb*_*rid 5 android alignment android-layout android-linearlayout
我有5张图像,它们应该以线性布局水平放置,并且应该以合理的方式放置,第3张图像位于屏幕中央。所有图像具有相同的宽度和高度。
即图像之间的填充应动态调整。
谢谢
尝试这个:
<?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>
Run Code Online (Sandbox Code Playgroud)
Beetwen每一个都用参数ImageView添加空View:android:layout_width="0dp"
android:layout_weight="1"
| 归档时间: |
|
| 查看次数: |
2386 次 |
| 最近记录: |