简体   繁体   English

如何在Android中没有工具栏的情况下在片段中对布局进行视差滚动

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

I am using a Fragment in my android app. 我在我的Android应用程序中使用Fragment This Fragment does not have it's own Toolbar or android.support.v7.widget.Toolbar element, but rather uses getSupportActionBar() from it's parent activity. 这个Fragment没有自己的Toolbarandroid.support.v7.widget.Toolbar元素,而是使用它的父活动中的getSupportActionBar() Now, I want to set up Parallax Scrolling of the ScrollView over infoRL . 现在,我想成立Parallax Scrolling的的ScrollViewinfoRL

I checked some resources online, but most of them are about Parallax a ScrollView over an ImageView , or use Toolbar s in the layout. 我在线检查了一些资源,但大多数都是关于Parallax的ScrollView而不是ImageView ,或者在布局中使用Toolbar

So I was wondering how I can go about structuring them. 所以我想知道如何构建它们。

Here is how my layout.xml file is structured. 以下是我的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.

相关问题 视差折叠工具栏错误的滚动和布局 - Parallax Collapse Toolbar wrong scroll and layout 如何在 Xamarin Android Fragment 中加载工具栏布局 - How to load Toolbar layout in Xamarin Android Fragment Android Fragment与工具栏布局重叠 - Android Fragment is overlapping Toolbar Layout 片段布局接管工具栏和浮动按钮 - Fragment layout takes over toolbar and floating button android如何使用Fragment RecyclerView滚动工具栏中的Fragment Tablayout ViewPager滚动BottomNavigationView - android how to scroll BottomNavigationView with Fragment Tablayout ViewPager in side Fragment RecyclerView Scroll toolbar 折叠工具栏布局在片段中不起作用-Android - Collapsing Toolbar Layout not working in Fragment - Android 工具栏在那里时,带有片段的android布局中断 - android layout with fragment breaks when toolbar is there Android:工具栏布局在当前片段上缩小 - Android: Toolbar layout denpend on current fragment 如何使滚动视图滚动到另一个布局上,布局保持完整但在滚动内容后面 - how to make a scroll view to scroll over another layout with the layout behind staying intact but behind scroll content 如何使“工具栏”与Fragment中的内容一起滚动? - How to make Toolbar scroll with content in Fragment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM