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)文章
僅4行代碼實(shí)現(xiàn)Android快速文件下載
僅4行代碼實(shí)現(xiàn)Android快速文件下載,這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)快速文件下載功能的方法,感興趣的小伙伴們可以參考一下2016-07-07Kotlin基礎(chǔ)學(xué)習(xí)之位運(yùn)算
一提起位運(yùn)算,人們往往想到它的高效性,無(wú)論是嵌入式編程還是優(yōu)化系統(tǒng)的核心代碼,適當(dāng)?shù)倪\(yùn)用位運(yùn)算總是一種迷人的手段,下面這篇文章主要給大家介紹了關(guān)于Kotlin基礎(chǔ)學(xué)習(xí)之位運(yùn)算的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考下。2017-11-11解析Android開(kāi)發(fā)中多點(diǎn)觸摸的實(shí)現(xiàn)方法
多點(diǎn)觸摸(MultiTouch),指的是允許計(jì)算機(jī)用戶同時(shí)通過(guò)多個(gè)手指來(lái)控制圖形界面的一種技術(shù)。與多點(diǎn)觸摸技術(shù)相對(duì)應(yīng)的就是單點(diǎn)觸摸,單點(diǎn)觸摸的設(shè)備已經(jīng)有很多年了,小尺寸的有觸摸式的手機(jī),大尺寸的最常見(jiàn)的就是銀行里的ATM機(jī)和排隊(duì)查詢機(jī)等等2013-05-05Android?中?FrameLayout?布局及屬性的使用詳解
這篇文章主要介紹了Android?中?FrameLayout?布局及屬性的使用,FrameLayout?在實(shí)現(xiàn)簡(jiǎn)單布局時(shí)非常方便,特別適用于疊加式布局,如顯示疊加的圖層或浮動(dòng)按鈕等,需要的朋友可以參考下2024-03-03Android WebViewClient 的 `shouldOverrideUrlLoa
這篇文章主要介紹了Android WebViewClient 的 shouldOverrideUrlLoading方法,了解并正確實(shí)現(xiàn) WebViewClient 中的 shouldOverrideUrlLoading 方法對(duì)于在你的 Android 應(yīng)用中提供順暢且安全的瀏覽體驗(yàn)至關(guān)重要,需要的朋友可以參考下2024-07-07Android開(kāi)發(fā)之Picasso通過(guò)URL獲取用戶頭像的圓形顯示
這篇文章主要介紹了android開(kāi)發(fā)之Picasso通過(guò)URL獲取用戶頭像的圓形顯示,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-06-06Android Studio發(fā)布項(xiàng)目到Jcenter倉(cāng)庫(kù)步驟(圖文)
這篇文章主要介紹了Android Studio發(fā)布項(xiàng)目到Jcenter倉(cāng)庫(kù)步驟(圖文),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-10-10