視差滾動(Parallax Scroll)效果的滾動視圖:ParallaxScrollView

jopen 10年前發布 | 56K 次閱讀 Android開發 移動開發 ParallaxScrollView

ParallaxScrollView實現具有視差滾動(Parallax Scroll)效果的滾動視圖。所謂視差滾動,就是屏幕有兩層滾動視圖,兩層滾動視圖的滾動速度不一樣,一般來說前面的滾動視圖的滾動速度比底部的滾動視圖的滾動速度要快,從而造成三維滾動效果。可以調整視差滾動參數,參數越小,兩層的滾動速度相差越大,視差滾動效果越明顯。

<couk.jenxsol.parallaxscrollview.views.ParallaxScrollView xmlns:tools="

<!-- 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></pre>

項目主頁:http://www.baiduhome.net/lib/view/home/1389766760851

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!