为Android的界面设计增加跳跃效果
为Android的界面设计增加跳跃效果
先贴出动画效果图(GIF截图比较业余,见谅见谅)
设计的思路是,为一个View增加跳起和落下的动画效果,然后为这个View加一个背景View作为运动的影子,进行同步运动。
首先,根据期望的效果,确定Activity的主题色调,比如我这里的背景色用的是透明渐变的灰黑色,自然就不能再使用黑色的显示主题,我选用的是Light(Android:theme="@android:style/Theme.Light")
为Android的界面设计增加跳跃效果源码下载:
免费下载地址在 http://linux.bkjia.com/
用户名与密码都是www.bkjia.com
具体下载目录在 /pub/Android源码集锦/2011年/11月/为Android的界面设计增加跳跃效果/
接着设计一个布局,因为阴影和前景是重叠关系,布局我选用RelativeLayout,下面是我的布局代码:
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <ImageView
- android:id="@+id/imageViewShadow"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_alignBottom="@+id/imageViewItem"
- android:layout_marginBottom="-5px"
- android:src="@drawable/shadow" />
- <ImageView
- android:id="@+id/imageViewItem"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:src="@drawable/test" />
- </RelativeLayout>
|
评论暂时关闭