ViewFlipper實(shí)現(xiàn)上下翻滾輪播效果
一種可以設(shè)置滑動(dòng)動(dòng)畫的控件,只顯示一行布局,在布局文件中的ViewFlipper控件中順序?qū)懞妹恳恍械牟季?/p>
(1).MainActivity.java:
ViewFlipper mFlipper = ((ViewFlipper) this.findViewById(R.id.flipper)); mFlipper.startFlipping(); // 設(shè)置進(jìn)入動(dòng)畫 mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_up_in)); // 設(shè)置滾出動(dòng)畫 mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_up_out));
(2).activity_main.xml:
<ViewFlipper
android:id="@+id/flipper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:flipInterval="3000" > // 設(shè)置滑動(dòng)間隔時(shí)間(毫秒)
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/animation_2_text_1"
android:textSize="26sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/animation_2_text_2"
android:textSize="26sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/animation_2_text_3"
android:textSize="26sp" />
</ViewFlipper>
(3).push_up_in.xml:(動(dòng)畫資源文件)
<set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="300"/> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" /> </set>
push_up_out.xml:
<set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="300"/> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" /> </set>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Android實(shí)現(xiàn)橫豎屏切換的實(shí)例代碼
本篇文章主要介紹了Android實(shí)現(xiàn)橫豎屏切換的實(shí)例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-06-06
Android使用ViewPager實(shí)現(xiàn)類似laucher左右拖動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了Android使用ViewPager實(shí)現(xiàn)類似laucher左右拖動(dòng)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05
Android實(shí)現(xiàn)自定義輪播圖片控件詳解
這篇文章給大家主要介紹了Android實(shí)現(xiàn)自定義輪播圖片控件的詳細(xì)過(guò)程,文中通過(guò)實(shí)例代碼介紹的很詳細(xì),相信會(huì)對(duì)大家的理解和學(xué)習(xí)很有幫助,感興趣的朋友們下面來(lái)一起看看吧。2016-10-10
ShareSDK造成App崩潰的一個(gè)BUG原因分析以及Fix方法
這篇文章主要介紹了ShareSDK造成App崩潰的一個(gè)BUG原因分析以及Fix方法,使用的是Cocos2d-x專用ShareSDK組件,需要的朋友可以參考下2014-04-04

