开发者

Gif animation as a background for a layout

Like iPhone I want to set a gif animation as a background for android layout. is it possible? If yes someone kindly share your knowledge.

开发者_如何学运维

Thanks!


Yes, it is possible and also very simple. First you set or declare main layout is RelativeLayout, then inside this main layout set your required layout. Both height and width are match_parent. After you set your gif file XML code which is outside of inside layout and inside of main layout.

Something like this:

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

In here I am using a third party lib to load the gif file and it's build path is

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜