【发布时间】:2021-02-25 18:16:26
【问题描述】:
我为我的新警报应用程序编写了一个简单的线性 RecycleView。由于我对 Android 编程非常陌生,我遇到了这样一个问题:现在,我拥有的所有项目都是从上到下显示的,即使只有 3 个项目。它看起来不太好,也不方便。如果列表中只有少数项目,有什么方法可以将它们显示在中间,而不是从上到下?
谢谢!!
我目前的主要 XML 代码是:
<?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"
android:background="@drawable/background"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="true"
android:scrollbars="vertical"
android:layout_marginTop="27dp"
android:layout_marginBottom="36dp"
android:requiresFadingEdge="vertical|horizontal"
tools:listitem="@layout/alarms_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】:
标签: android android-studio android-recyclerview