ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

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

2019-07-06 02:25:25  阅读:212  来源: 互联网

标签:android layout android-fragments scrollview parallax


我在我的Android应用程序中使用片段.
这个Fragment没有自己的Toolbar或android.support.v7.widget.Toolbar元素,而是使用它的父活动中的getSupportActionBar().现在,我想通过infoRL设置ScrollView的ScrollView滚动.

我在线检查了一些资源,但大多数都是关于Parallax的ScrollView而不是ImageView,或者在布局中使用工具栏.

所以我想知道如何构建它们.

以下是我的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" />

标签:android,layout,android-fragments,scrollview,parallax
来源: https://codeday.me/bug/20190706/1393234.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有