视差滚动(Parallax Scroll)效果的滚动视图:ParallaxScrollView

jopen 11年前

ParallaxScrollView实现具有视差滚动(Parallax Scroll)效果的滚动视图。所谓视差滚动,就是屏幕有两层滚动视图,两层滚动视图的滚动速度不一样,一般来说前面的滚动视图的滚动速度比底部的滚动视图的滚动速度要快,从而造成三维滚动效果。可以调整视差滚动参数,参数越小,两层的滚动速度相差越大,视差滚动效果越明显。

<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>

项目主页:http://www.open-open.com/lib/view/home/1389766760851