我正在尝试创建一个布局,我想在其右下角的图像按钮上方放置一个浮动操作按钮。我目前正在使用约束布局。有办法吗?
编辑:
这是我当前的实现方式:
<ImageButton
android:id="@+id/option1_button"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:baselineAlignBottom="true"
android:cropToPadding="false"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/icon1" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/option1_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/option1_button"
app:layout_constraintEnd_toEndOf="@+id/option1_button"
app:layout_constraintStart_toEndOf="@+id/option1_button"
app:layout_constraintTop_toTopOf="@+id/option1_button"
android:src="@drawable/gallery"
app:fabSize="mini"/>
答案 0 :(得分:0)
如果仅将浮动按钮约束到顶部以限制图像视图(约束顶部和底部),并对水平包含项执行相同操作(它们应在视图的右侧),则可以实现此目的
POST image_tag_index/_search {query: "redish"} -> [ "red" ]
POST images/_search {query: {"red" > 0.5}} -> [ {id: 1}, {id: 3}]
根据评论进行编辑:
<?xml version="1.0" encoding="utf-8"?>
<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">
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:background="@color/buttonColor"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="Button"
app:layout_constraintBottom_toTopOf="@+id/button3"
app:layout_constraintEnd_toEndOf="@+id/button3"
app:layout_constraintStart_toEndOf="@+id/button3"
app:layout_constraintTop_toTopOf="@+id/button3" />
</androidx.constraintlayout.widget.ConstraintLayout>