Android UI Libs之android-gif-drawable

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" />  
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容