Android 手機衛士--平移動畫實現

來源:互聯網
上載者:User

標籤:

本文實現如下幾個介面之間的平移動畫實現

本文地址:http://www.cnblogs.com/wuyudong/p/5954847.html,轉載請註明出處。

分析:

導航介面移動過程中,平移動畫
上一頁移入動畫(-螢幕寬度,y)------>(0,y)
上一頁移齣動畫(0,y)-------------->(螢幕寬度,y)

下一頁移入動畫(螢幕寬度,y)-------------->(0,y)
下一頁移齣動畫(0,y)-------------->(-螢幕寬度,y)

在res檔案夾下建立anima檔案夾,在檔案夾下建立四個translate.xml類型的檔案

相關的代碼如下:

pre_in_anim.xml

<?xml version="1.0" encoding="utf-8"?><!-- -100%p 負一螢幕的寬度大小值 --><translate    xmlns:android="http://schemas.android.com/apk/res/android"    android:fromXDelta="-100%p"    android:toXDelta="0"    android:duration="500"></translate>

pre_out_anim.xml

<?xml version="1.0" encoding="utf-8"?><translate    xmlns:android="http://schemas.android.com/apk/res/android"    android:fromXDelta="0"    android:toXDelta="100%p"    android:duration="500"></translate>

next_in_anim.xml

<?xml version="1.0" encoding="utf-8"?><translate    xmlns:android="http://schemas.android.com/apk/res/android"    android:fromXDelta="100%p"    android:toXDelta="0"    android:duration="500"></translate>

next_out_anim.xml

<?xml version="1.0" encoding="utf-8"?><translate    xmlns:android="http://schemas.android.com/apk/res/android"    android:fromXDelta="0"    android:toXDelta="-100%p"    android:duration="500"></translate>

接著在4個介面的代碼中的按鈕點擊事件中添加下面的代碼

在prePage按鈕中添加:

overridePendingTransition(R.anim.pre_in_anim, R.anim.pre_out_anim);

在nextPage按鈕中添加:

overridePendingTransition(R.anim.next_in_anim, R.anim.next_out_anim);

 

Android 手機衛士--平移動畫實現

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.