Gif动画作为布局的背景

时间:2011-05-04 10:24:54

标签: android-layout

像iPhone一样,我想设置一个gif动画作为android布局的背景。可能吗?如果是的话,有人会分享你的知识。

谢谢!

1 个答案:

答案 0 :(得分:0)

是的,这是可能的,也很简单。 首先设置或声明主布局为RelativeLayout,然后在此主布局中设置所需的布局。 高度和宽度均为match_parent。 设置gif文件XML代码后,它在内部布局之外和主布局内部。

这样的事情:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

         *********** here you create your GUI layout *********

    </RelativeLayout>

*************** Here your gif file xml code, here i'm using ex. lib ***********

      <pl.droidsonroids.gif.GifTextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/butterflyanimation"
            android:layout_margin="15dp"
            android:layout_centerInParent="true"/>

</RelativeLayout>

在这里,我使用第三方lib加载gif文件,它的构建路径是

 compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'