如何使3个imageButtons响应?

问题描述 投票:-1回答:2

我正在尝试实现以下目标:

enter image description here

一个[占据整个屏幕的三个图像按钮菜单,其中三个必须是等于高度宽度将是设备的,我很难做到这一点,使用ConstraintLayout可以使它“响应”,但取决于设备大小,出现间隙,不确定原因:

enter image description here

这是我的布局:

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#921B1F33" tools:context="com.example.minacar.MainActivity"> <ImageButton android:id="@+id/transferButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustViewBounds="true" android:contentDescription="@string/descripcion_button_1" android:scaleType="fitXY" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/menutransfer" /> <ImageButton android:id="@+id/rentaCarButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustViewBounds="true" android:contentDescription="@string/descripcion_button_2" android:scaleType="fitXY" app:layout_constraintBottom_toTopOf="@+id/transferButton" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/menurent" /> <ImageButton android:id="@+id/carButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:adjustViewBounds="true" android:contentDescription="@string/descripcion_button_3" android:scaleType="fitXY" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/transferButton" app:srcCompat="@drawable/menucar" />

非常感谢您的帮助或指导,谢谢!! >>

不确定是否有用,我使用的图像是三个相同的大小,1417x929 PNG。

我正在尝试实现这样的目标:占据整个屏幕的三个图像按钮菜单,其中三个必须高度相等,宽度等于设备的宽度,我很难过...] >

java android android-imagebutton
2个回答
0
投票
我建议在这种情况下使用LinerLayout,将每个元素的权重设置为1,并且match_parent的宽度将实现所需的行为。

<LinerLayout android:orientation = "vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#921B1F33" tools:context="com.example.minacar.MainActivity"> <ImageButton android:id="@+id/carButton" android:layout_width="match_parent" android:layout_height="0dp" android:weight = "1" /> <ImageButton android:id="@+id/carButton" android:layout_width="match_parent" android:layout_height="0dp" android:weight = "1" /> <ImageButton android:id="@+id/carButton" android:layout_width="match_parent" android:layout_height="0dp" android:weight = "1" /> <LinerLayout>


0
投票
您可以将链条用于:
© www.soinside.com 2019 - 2024. All rights reserved.