У меня есть макет с 3 ImageButtons
один справа от других следующим образом:Совместите центр IMAGEBUTTON на одной линии андроида
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main3con"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main3">
<TextView
android:id="@+id/textx"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="cards"
android:textSize="25dp" />
<ImageButton
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textx"
android:src="@drawable/random_40x40" />
<ImageButton
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button"
android:layout_toEndOf="@+id/button"
android:layout_toRightOf="@+id/button"
android:src="@drawable/add_40x40" />
<ImageButton
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button3"
android:layout_toEndOf="@+id/button3"
android:layout_toRightOf="@+id/button3"
android:src="@drawable/reset_40x40" />
<ListView
android:id="@+id/listVieww"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/button"
android:layout_alignParentStart="true"
android:text="New Text" />
</RelativeLayout>
Как вы видите, я выровнял TextView
«@ + ID/textx» к центру, используя android:gravity="center"
, и я хочу выровнять ImageButtons
в центр, я попытался окружить его LinearLayout
и такие вещи, но я не знаю, как это сделать. Я хочу выровнять их в одной строке, что означает три первые кнопки here.
Спасибо! плавно – DAVIDBALAS1