首页 > 其他分享 >ParallaxScrollView有视差的ScrollView

ParallaxScrollView有视差的ScrollView

时间:2023-04-06 21:40:33浏览次数:54  
标签:foreground based parent ScrollView ParallaxScrollView will background 视差



Usage


Look at the demo layout for implimentation.



The basics are, that you need two views added to the ParallaxScrollView and it will do the rest.



The first View added is the Background


The second View added is the Foreground.


Layout and measuring is based roughly around a FrameLayout.



The foreground view gets wrapped with a ObservableScrollView regardless with what you put in there, so if you want full control of layout impliment like below.



Attributes



app:parallexOffset="0.3" - this number needs to be between 0.1 and 1.0. otherwise it defaults to 0.3.


ParallexScrollView.setParallexOffset(float) - this is the programatic version of the offset value.



Background The background will at the very minimum be the exact size as the parent (matches the ParallexScrollView size). If the ScrollView content is larger than the parent then background calculates a factor based on the scroll capacity, i.e. a parallexFactor of 0.5 will approximatly move the background at half the rate of the foreground scroll.



Foreground Make sure you fill the parent, I haven't overridden this but I may in the future if people have issues with it, as the background will scroll based on the size of foreground content.



Example Layout

<couk.jenxsol.parallaxscrollview.views.ParallaxScrollView xmlns:tools="http://schemas.android.com/tools"    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:parallexOffset="0.25" >

    <!-- Background -->

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:scaleType="fitXY"
        android:src="@drawable/bg_sky" />

    <!-- Foreground -->
    <!-- You can place any of the items below as the foreground, but for most control, add the scroll view yourself. -->

    <couk.jenxsol.parallaxscrollview.views.ObservableScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="260dp"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingBottom="@dimen/spacing"
            android:paddingTop="@dimen/spacing" >

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/white"
                android:padding="@dimen/spacing"
                android:text="@string/hello_world" />

        </LinearLayout>
    </couk.jenxsol.parallaxscrollview.views.ObservableScrollView>

</couk.jenxsol.parallaxscrollview.views.ParallaxScrollView>


标签:foreground,based,parent,ScrollView,ParallaxScrollView,will,background,视差
From: https://blog.51cto.com/u_5454003/6174153

相关文章

  • ScrollView中浮动条的实现
    简单的浮窗http://www.open-open.com/lib/view/open1467185415741.htmlScrollView中如果内容比较长,往下拉的时候有一部分(通常是菜单)View就一直固定在屏幕顶端,像个浮动条一样,该效果Web页面使用比较多。实现这种效果需要重写ScrollView的onScrollChanged()......
  • 懒加载的Scrollview
    要实现一个功能:当Scrollview滑动到最底端的时候需要触发事件加载其他数据。很多人都以为ScrollView可以像ListViev那样setOnScrollListener,其实沒那么简单,因为ScrollView压根就没有该接口,在baidu上兜了一圈没有找到合适的答案,没办法只能google去了,居然一下子......
  • android 解决ScrollView嵌套ListView的问题,不能全屏,全屏不能显示下面控件
    在开发中遇到ScrollView嵌套ListView的问题,最开始发出不能全屏,效果是这样的;但我想要的效果是这样的:下面看一下布局文件:<?xmlversion="1.0"encoding="utf-8"?><ScrollViewxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_p......
  • Android控制ScrollView滑动速度
    前言由于各个Android平板触摸屏的材质不一样,滑动效果会有一些区别,有的比较灵敏,有的比较迟钝,这里就遇到了要求控制滑动速度的需求... 声明正文翻阅查找ScrollView的......
  • ParallaxViewPager:ViewPager的视差背景效果
    这是一个针对技术开发者的一个应用,你可以在掘金上获取最新最优质的技术干货,不仅仅是Android知识、前端、后端以至于产品和设计都有涉猎,想成为全栈工程师的朋友不要错过!所谓......
  • Android 页面上滑置顶悬停实现 (CoordinatorLayout+AppBarLayout+CollapsingToolbarLa
    我开始炒冷饭了啊,有人说这套组合已经被用烂了,有人说这玩意谁都会,其实没有人说哈,我就是怕被人说,提前预警哈.最近,工作比较忙,好久都没有写一下博客来说点什么.刚刚我去......
  • 视差映射
    视差映射ParallaxMapping 主要为了赋予模型表面遮挡关系的细节。引入了一张高度图可以和法线贴图一起使用,来产生一些真实的效果高度图一般视为顶点位移来使用,此时......
  • react-native ScrollView嵌套滚动
    是否有相关属性可以兼容scrollview嵌套问题?在阅读一番官方文档后,发现了一个属性nestedScrollEnabled,代码如下:nestedScrollEnabled={true}<ScrollView><Viewstyle=......
  • Android Studio GridLayout & ScrollView
    GridLayout是网格布局感觉在设计表格的时候会有一些用处知识点只有两个 columnCount属性,指定了网格的列数,即每行放多少个rowCount属性,指定行数,即每行放多少个要注意......
  • scrollView 嵌套 recyclerview 时 BaseQuickAdapter 九宫格图片拖拽到底部删除
    九宫格图片布局,长按直接拖拽图片,长按时显示底部删除布局,拖拽到删除布局处松手可删除布局,最后添加按钮不可拖拽,基于BaseQuickAdapter基础上实现BaseQuickAdapter确实很......