Bru*_*nec 6 android background animated
问题简单,但是没有找到任何简单的答案为Android初学者,如我...
如何在android中为背景绘制动画?
如果可能的话,我想通过一些简单易懂的方式来实现bakcground动画.
非常感谢您的帮助,问候,布鲁诺
编辑:经过一些谷歌搜索后,我设法完成了我的目标.我使用了hasanghaforian描述的方法和这个直截了当的动画示例中的应用机制http://code.google.com/p/android-animation-example/
您可以使用RelativeLayout或AbsoluteLayout,在其中放置一个图像(覆盖它的父项),然后安装活动的当前布局.现在,如果您为该图像设置动画,则您的活动背景似乎是动画的.
例如,假设这是您活动的当前布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
现在这个布局看起来像以前的布局,你可以为它的ID设置图像的动画img1(它看起来像背景:主布局的ound):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/img1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0dp"
android:layout_y="0dp"
android:src="@drawable/bright_sun" />
<LinearLayout
android:id="@+id/vg2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18495 次 |
| 最近记录: |