Android的活动 - 背景绘制动画背景、动画、Android

由网友(轻风吹清酒)分享简介:问题简单,但还没有发现针对Android初学者任何简单的答案,如我...... question simple, however haven't found any simple answer for android beginner such as I am...如何动画的背景绘制的机器人?How can I...

问题简单,但还没有发现针对Android初学者任何简单的答案,如我......

question simple, however haven't found any simple answer for android beginner such as I am...

如何动画的背景绘制的机器人?

How can I animate background drawable in android ?

我想如果可能的话用一些简单和易于tounderstand的方式来达到bakcground动画。

I'd like to achieve the bakcground animation if possible by some simple and easy-tounderstand way.

非常感谢帮助 问候,布鲁诺

Thanks a lot for help Regards, Bruno

编辑:一些google搜索后,我已经成功地实现我的目标。我已经使用hasanghaforian描述的方法和适用这一直截了当的动画例如http://$c$c.google.com/p/android-animation-example/

After some googling I've managed to accomplish my goal. I've used approach described by hasanghaforian and applied mechanics found in this straight-forward animation example http://code.google.com/p/android-animation-example/

推荐答案

您可以使用RelativeLayout的或AbsoluteLayout,将图像(覆盖它的父)在里面,然后装入activity.Now目前的布局,如果您设置动画的图像,看来你的活动,这样的背景动画。 例如,假设这是你的活动当前布局:

You can use RelativeLayout or AbsoluteLayout ,put an image (that covers it's parent) in it and then mount current layout of activity.Now if you set animation for that image,it seems that background of your activity animates. For example suppose this is current layout of your activity:

<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>

现在这个布局看起来像previous布局,您可以设置动画图像,它的ID是 IMG1 (它似乎backgr:ound的主要布局):

Now this layout looks like previous layout and you can set animation for image that it's ID is img1(it seems as backgr:ound of main layout):

<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>
阅读全文

相关推荐

最新文章