android中要水平均匀放置5个小图标,用什么布局好?有代码最好
android:layout_witdh="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=“1”
.../>
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=“1”
.../>
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=“1”
.../>
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=“1”
.../>
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=“1”
.../>
LinearLayout线性布局就行吧
用layout_weight,类似这种效果
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textSize="42sp" android:layout_weight="1">
<Button android:id="@+id/num4" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:textSize="42sp"
android:text="4" android:layout_weight="1" />
<Button android:id="@+id/num5" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:textSize="42sp"
android:text="5" android:layout_weight="1" />
<Button android:id="@+id/num6" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:textSize="42sp"
android:text="6" android:layout_weight="1" />
<Button android:id="@+id/multiply" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:textSize="42sp"
android:text="*" android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
</LinearLayout>
用网格或者listview