如何在回收站视图中滚动图像

时间:2016-02-14 14:04:34

标签: java android

我是Android编程的新手,我正在尝试在图像上滚动我的回收器视图

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/rootRL"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="160dp"
 android:background="@drawable/mydrawable">

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="160dp"
    android:id="@+id/rv"/>
</FrameLayout>

当我滚动时,回收者视图在图像下滚动而不是在它上面。我如何实现这种效果?

1 个答案:

答案 0 :(得分:0)

试试这个: -

通过设置backgroundImage使用FrameLayout:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/rootRL"
        android:layout_width="match_parent"
        android:layout_height="160dp"
        android:layout_marginTop="160dp"
        android:background="@drawable/tips"
        android:orientation="vertical">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>

通过设置backgroundImage使用LinearLayout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/rootRL"
        android:layout_width="match_parent"
        android:layout_height="160dp"
        android:layout_marginTop="160dp"
        android:background="@drawable/tips"
        android:orientation="vertical">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>

通过设置backgroundImage使用RelativeLayout:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/rootRL"
        android:layout_width="match_parent"
        android:layout_height="160dp"
        android:layout_marginTop="160dp"
        android:background="@drawable/tips">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </RelativeLayout>

在ImageView中使用RelativeLayout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/rootRL"
        android:layout_width="match_parent"
        android:layout_height="160dp"
        android:layout_marginTop="160dp">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/tips" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </RelativeLayout>
相关问题