You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除RecyclerView滑动指示器或修改其颜色为白色?

横向滑动RecyclerView的滑动指示器实现

我创建了3个支持左右横向滑动的RecyclerView,滑动时CardView下方会出现灰色指示器,滑动停止后指示器消失,再次滑动时会重新显示。

CardView下方的灰色滑动指示器

以下是对应的XML布局代码:

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

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="120dp"
        android:background="@drawable/flash_tablebar"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        android:layout_alignParentTop="true">

        <ImageView
            android:id="@+id/back_icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:src="@drawable/ic_arrow_back" />

        <RelativeLayout
            android:layout_marginLeft="20dp"
            android:id="@+id/relativeFlashcard"
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_toRightOf="@id/back_icon">
            <TextView
                android:id="@+id/title_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:layout_marginStart="30dp"
                android:text="Flashcards"
                android:textSize="40sp"
                android:textColor="#FFF" />
            <TextView
                android:id="@+id/subtext_flash"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:layout_below="@id/title_text"
                android:layout_marginStart="30dp"
                android:text="@string/swipe_left_for_more_cards"
                android:textSize="20sp"
                android:textColor="#FFF" />
        </RelativeLayout>
    </androidx.appcompat.widget.Toolbar>
    <LinearLayout
        android:gravity="center_horizontal"
        android:layout_marginTop="5dp"
        android:id="@+id/linearH1"
        android:orientation="horizontal"
        android:layout_marginStart="10dp"
        android:layout_width="match_parent"
        android:layout_below="@id/toolbar"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/textEasy"
            android:gravity="start"
            android:textStyle="bold"
            android:textSize="20sp"
            android:layout_marginTop="5dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/easy_cards"/>

        <ImageView
            android:layout_marginTop="11dp"
            android:layout_marginStart="10dp"
            android:layout_width="16dp"
            android:layout_height="16dp"
            android:src="@drawable/arrow" />

    </LinearLayout>
    <LinearLayout
        android:layout_below="@id/linearH1"
        android:layout_width="match_parent"
        android:id="@+id/linear1"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="5dp">
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerViewFlashcardsEasy"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:layout_marginEnd="5dp"
            android:layout_marginTop="15dp"
            android:scrollbars="horizontal">
        </androidx.recyclerview.widget.RecyclerView>
    </LinearLayout>
    <LinearLayout
        android:layout_marginTop="5dp"
        android:id="@+id/linearH2"
        android:orientation="horizontal"
        android:gravity="center_horizontal"
        android:layout_marginStart="10dp"
        android:layout_width="match_parent"
        android:layout_below="@id/linear1"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/textMedium"
            android:gravity="start"
            android:textStyle="bold"
            android:textSize="20sp"
            android:layout_marginTop="5dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/medium_cards"/>

        <ImageView
            android:layout_marginTop="11dp"
            android:layout_marginStart="10dp"
            android:layout_width="16dp"
            android:layout_height="16dp"
            android:src="@drawable/arrow" />

    </LinearLayout>
    <LinearLayout
        android:layout_below="@id/linearH2"
        android:id="@+id/linear2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="5dp">
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerViewFlashcardsMedium"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:layout_marginEnd="5dp"
            android:layout_marginTop="15dp"
            android:scrollbars="horizontal">
        </androidx.recyclerview.widget.RecyclerView>
    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="5dp"
        android:id="@+id/linearH3"
        android:orientation="horizontal"
        android:gravity="center_horizontal"
        android:layout_marginStart="10dp"
        android:layout_width="match_parent"
        android:layout_below="@id/linear2"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/textHard"
            android:gravity="start"
            android:textStyle="bold"
            android:textSize="20sp"
            android:layout_marginTop="5dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/medium_cards"/>

        <ImageView
            android:layout_marginTop="11dp"
            android:layout_marginStart="10dp"
            android:layout_width="16dp"
            android:layout_height="16dp"
            android:src="@drawable/arrow" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/linear3"
        android:layout_below="@id/linearH3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="5dp">
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerViewFlashcardsHard"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:layout_marginEnd="5dp"
            android:layout_marginTop="15dp"
            android:scrollbars="horizontal">
        </androidx.recyclerview.widget.RecyclerView>
    </LinearLayout>
</RelativeLayout>

内容的提问来源于stack exchange,提问作者vilnius19

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 06:07:02