實現Android界面滾動時控件隨著淡出:Discrollview

jopen 10年前發布 | 45K 次閱讀 Android開發 移動開發 Discrollview

實現在滾動Android界面時,界面的部件會逐漸淡出、平移或者縮放。效果如下動畫:Animated gif
使用示例:

<com.flavienlaurent.discrollview.lib.DiscrollView
    xmlns:android="

<com.flavienlaurent.discrollview.lib.DiscrollViewContent
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="600dp"
        android:background="@android:color/white"
        android:textColor="@android:color/black"
        android:padding="25dp"
        android:textSize="72sp"
        android:gravity="center"
        android:fontFamily="serif"
        android:text="Do you love cheese?" />

    <View
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="#007788"
        discrollve:discrollve_alpha="true"
        discrollve:discrollve_threshold="0.3" />

    <ImageView
        android:layout_width="200dp"
        android:layout_height="120dp"
        discrollve:discrollve_alpha="true"
        discrollve:discrollve_translation="fromLeft|fromBottom"
        android:src="@drawable/cheese1" />

    <View
        android:layout_width="match_parent"
        android:layout_height="200dp"
        discrollve:discrollve_fromColor="#88EE66"
        discrollve:discrollve_toColor="#000000" />

    <ImageView
        android:layout_width="220dp"
        android:layout_height="110dp"
        android:layout_gravity="right"
        android:src="@drawable/cheese2"
        discrollve:discrollve_translation="fromRight" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="20dp"
        android:fontFamily="serif"
        android:gravity="center"
        android:text="When the cheese comes out everybody's happy pecorino red leicester"
        android:textSize="18sp"
        discrollve:discrollve_alpha="true"
        discrollve:discrollve_translation="fromBottom" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:layout_gravity="center"
        android:src="@drawable/ilovecheese_heart"
        discrollve:discrollve_scaleX="true"
        discrollve:discrollve_scaleY="true"  />

</com.flavienlaurent.discrollview.lib.DiscrollViewContent>

</com.flavienlaurent.discrollview.lib.DiscrollView></pre>

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

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