現在、画面の高さの半分しかかからないレイアウトでは、私は4 ImageButton
を持っています。 ImageButton
をレイアウトに均等に配置したいと思います。ここで私が持っているものです。レイアウト内のImageButtonを均等に整列する方法
<?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">
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@mipmap/feed_button"
android:background="@android:color/transparent"
android:layout_weight="1" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@mipmap/feed_button"
android:background="@android:color/transparent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:orientation="horizontal">
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@mipmap/feed_button"
android:background="@android:color/transparent"
android:layout_weight="1" />
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@mipmap/feed_button"
android:background="@android:color/transparent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
これは動作しますが、ここでの結果であることから:
問題は、1:私は、各ボタンの下にテキストを追加したいと私はないですどのように動作するのか、2:ボタンの一部であるかのように、ImageButton
の左右の白い点がアクティブになっています。これを行うより良い方法はありますか?
FrameLayout内にTextViewと共にImageButtonを配置することができます。 – user5195185
ボタンであるため、「アクティブです」。特定のサイズの背景画像を設定し、ImageButtons(これは「インテリジェント」に拡張します)にlayout_weight = "1"で "0dp"を設定しました。ボタンやラッパーに "wrap_content"を入れて、マージンを使って作業することができます。 – user5195185