以下是修正后的布局代码,将加号按键放置在屏幕的右上方:

<androidx.constraintlayout.widget.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- 条目列表 -->
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@id/addButton" />

    <!-- +号按键 -->
    <ImageButton
        android:id="@+id/addButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_add"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintVertical_bias="0.0" />

</androidx.constraintlayout.widget.ConstraintLayout>

在这个修正后的布局中,我们将加号按键的顶部约束设置为父布局的顶部,这样就能够实现加号按键位于屏幕的右上方。

再次对之前的错误回答表示抱歉,希望这次能够满足您的需求。

Android布局:将加号按钮放置在屏幕右上角

原文地址: https://www.cveoy.top/t/topic/RYK 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录