歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 為Android的界面設計增加跳躍效果

為Android的界面設計增加跳躍效果

日期:2017/3/1 11:01:53   编辑:Linux編程

先貼出動畫效果圖(GIF截圖比較業余,見諒見諒)



設計的思路是,為一個View增加跳起和落下的動畫效果,然後為這個View加一個背景View作為運動的影子,進行同步運動。

首先,根據期望的效果,確定Activity的主題色調,比如我這裡的背景色用的是透明漸變的灰黑色,自然就不能再使用黑色的顯示主題,我選用的是Light(Android:theme="@android:style/Theme.Light")

為Android的界面設計增加跳躍效果源碼下載:

免費下載地址在 http://linux.linuxidc.com/

用戶名與密碼都是www.linuxidc.com

具體下載目錄在 /pub/Android源碼集錦/2011年/11月/為Android的界面設計增加跳躍效果/

接著設計一個布局,因為陰影和前景是重疊關系,布局我選用RelativeLayout,下面是我的布局代碼:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. android:orientation="vertical" >
  6. <ImageView
  7. android:id="@+id/imageViewShadow"
  8. android:layout_width="wrap_content"
  9. android:layout_height="wrap_content"
  10. android:layout_centerHorizontal="true"
  11. android:layout_alignBottom="@+id/imageViewItem"
  12. android:layout_marginBottom="-5px"
  13. android:src="@drawable/shadow" />
  14. <ImageView
  15. android:id="@+id/imageViewItem"
  16. android:layout_width="wrap_content"
  17. android:layout_height="wrap_content"
  18. android:layout_centerHorizontal="true"
  19. android:layout_centerVertical="true"
  20. android:src="@drawable/test" />
  21. </RelativeLayout>
為了確保顯示的順序,需要在布局文件中先放置背景View,然後再放置前景View,確保顯示時背景總是被前景View所覆蓋。背景View的位置設計為底部和前景View對齊,並向下縮進幾個像素,這樣在落地時可以顯示幾個像素的陰影。
Copyright © Linux教程網 All Rights Reserved