Android UI Libs之android-gif-drawable
我們經常需要顯示gif圖片,但是Android自帶的ImageView不能完全顯示gif圖片,它只會顯示gif圖片的第1幀。那我們要顯示gif圖片怎么辦。本著不重復“造輪子”的原則,本人推薦使用android-gif-drawable。android-gif-drawabl的功能很強大,不僅可以在顯示gif圖片,還可以讓gif圖片作為文本和按鈕的背景圖片顯示等。
要使用 android-gif-drawabl,首先要添加依賴compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15'
顯示gif圖片:
<pl.droidsonroids.gif.GifImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/image"
/>
以gif圖片作為文本的背景圖片:
<pl.droidsonroids.gif.GifTextView
android:text="hello"
android:background="@drawable/image"
android:layout_width="100dp"
android:layout_height="100dp" />
以gif圖片作為文按鈕的背景圖片:
<pl.droidsonroids.gif.GifImageButton
android:text="hello"
android:background="@drawable/image"
android:layout_width="100dp"
android:layout_height="100dp" />