【问题标题】:Reverse scroll view in XMLXML中的反向滚动视图
【发布时间】:2020-09-07 02:50:52
【问题描述】:

我正在制作一个 android 应用程序,并希望滚动从底部开始,然后根据用户输入向上滚动。目前,滚动从底部开始,只有向上滑动才能移动滚动并在底部显示空白空间,方向错误。这是我的第一个项目,任何帮助表示赞赏。谢谢。

<androidx.core.widget.NestedScrollView
    android:id="@+id/scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginBottom="0dp"
    app:layout_constraintBottom_toBottomOf="parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom"
        android:layout_marginStart="0dp"
        android:layout_marginEnd="0dp"
        android:layout_marginBottom="0dp"
        android:orientation="vertical">

    <androidx.cardview.widget.CardView
            android:id="@+id/redCard"
            android:layout_width="match_parent"
            android:layout_height="96dp"
            android:layout_marginStart="16dp"
            android:layout_marginEnd="16dp"
            android:layout_marginBottom="96dp"
            android:background="#FF5F5F"
            app:cardBackgroundColor="#F44336"
            app:cardCornerRadius="8dp">

            <ImageButton
                android:id="@+id/houseButton"
                android:layout_width="64dp"
                android:layout_height="64dp"
                android:layout_marginStart="16dp"
                android:layout_marginTop="16dp"
                android:background="#00FFFFFF"
                android:contentDescription="@string/app_name"
                android:scaleType="centerInside"
                android:src="@drawable/house_icon" />

            <ImageButton
                android:id="@+id/foodButton"
                android:layout_width="64dp"
                android:layout_height="64dp"
                android:layout_marginStart="96dp"
                android:layout_marginTop="16dp"
                android:background="#00FFFFFF"
                android:contentDescription="@string/app_name"
                android:scaleType="centerInside"
                app:srcCompat="@drawable/food_icon" />

        </androidx.cardview.widget.CardView>
     
        </LinearLayout>

</androidx.core.widget.NestedScrollView>

【问题讨论】:

    标签: xml android-layout scrollview


    【解决方案1】:

    可以使用布局管理器在回收器视图上完成,如果我们首先将布局管理器设置为setReverseLayout(true)并将其附加到回收器视图,滚动将从底部以及其中的项目开始。

    【讨论】:

      猜你喜欢
      • 2015-08-10
      • 1970-01-01
      • 2020-10-05
      • 2018-08-21
      • 2019-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-14
      相关资源
      最近更新 更多