簡體   English   中英

如何在Android中沒有工具欄的情況下在片段中對布局進行視差滾動

[英]How to parallax scroll a layout over another in a Fragment without a Toolbar in Android

我在我的Android應用程序中使用Fragment 這個Fragment沒有自己的Toolbarandroid.support.v7.widget.Toolbar元素,而是使用它的父活動中的getSupportActionBar() 現在,我想成立Parallax Scrolling的的ScrollViewinfoRL

我在線檢查了一些資源,但大多數都是關於Parallax的ScrollView而不是ImageView ,或者在布局中使用Toolbar

所以我想知道如何構建它們。

以下是我的layout.xml文件的結構。

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

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

<LinearLayout
    android:id="@+id/infoRL"
    android:orientation="vertical"
    android:paddingTop="40dp"
    android:layout_width="match_parent"
    android:paddingBottom="40dp"
    android:layout_height="wrap_content"
    android:background="@color/treasur_yellow"
    android:layout_below="@+id/custom_toolbar_element">


    <com.joooonho.SelectableRoundedImageView
        android:id="@+id/profileImageView"
        android:layout_width="128dp"
        android:layout_gravity="center_horizontal"
        android:layout_height="128dp"
        android:layout_centerHorizontal="true"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        app:sriv_left_bottom_corner_radius="0dp"
        app:sriv_oval="true"
        app:sriv_right_bottom_corner_radius="0dp" />


    <hunt.ayush.com.traserhunt.utility.CentuaryGothicTextView
        android:id="@+id/userName"
        android:layout_gravity="center_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageBorderLayout"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="15dp"
        android:text="Fetching Name"
        android:textColor="@color/treasure_black"
        android:textSize="20sp" />

    </LinearLayout>

    <ScrollView />
</RelativeLayout>
Please try with frame layout once

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:id="@+id/heroImageView"
    android:layout_width="match_parent"
    android:layout_height="250dp"
    android:background="@drawable/wallpaper"
    android:scaleType="fitCenter" />

<ListView
    android:id="@+id/listView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="#9E9E9E"
    android:dividerHeight="1dp"
    android:scrollbars="none"></ListView>

<TextView
    android:id="@+id/stickyView"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="#222"
    android:gravity="center_vertical"
    android:paddingLeft="10dp"
    android:text="Heading1"
    android:textColor="#fff"
    android:textSize="20sp"
    android:textStyle="bold" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM