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.+'
精彩评论