【问题标题】:How to hide Items on recyclerview scrollbar gradually如何逐渐隐藏recyclerview滚动条上的项目
【发布时间】:2019-03-15 16:13:17
【问题描述】:

如何逐渐隐藏 recyclerview 滚动条上的项目

我想要这样的图片

工具栏

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="55dp"
    android:background="@color/posts_toolbar"
    app:contentInsetLeft="0dp"
    app:contentInsetStart="0dp">

    <com.salah250.forvo.Funcations.TextViewFont
        android:id="@+id/txt_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/posts_title"
        android:textColor="@color/posts_title"
        android:textSize="18dp" />

</android.support.v7.widget.Toolbar>

活动帖

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="@color/posts_main"
    android:orientation="vertical"
    tools:context=".Posts.PostsActivity">

    <include layout="@layout/toolbar_posts" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_posts"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:overScrollMode="never" />

</LinearLayout>

在我可以在这里发帖之前我看了看,我根本找不到任何谈论它的话题,我希望能得到一些想法。

【问题讨论】:

标签: android android-studio android-recyclerview android-animation


【解决方案1】:

你可以把渐变图片放在你的RecyclerView前面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="@color/posts_main"
    android:orientation="vertical"
    tools:context=".Posts.PostsActivity">

    <include layout="@layout/toolbar_posts" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rv_posts"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:overScrollMode="never" />

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:src="@drawable/gradient"/>

    <FrameLayout/>            

</LinearLayout>

@drawable/gradient.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle" >

    <gradient
    android:angle="270"
    android:endColor="#00FFFFFF"
    android:startColor="#302e43" />

</shape>

然后将渐变高度的空视图添加到RecyclerView 的标题中,这样最上面的项目就不会褪色

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-17
    • 2019-09-05
    • 1970-01-01
    • 2018-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多