Search code examples
androidandroid-toolbaranimated-gif

adding gif on toolbar in android


I am new to android and java, i need solution for a problem that I want a gif in the toolbar in android which is always running when the screen shows up, I am able to add gif using koral's library but I could not figure it out that how can I add this gif in toolbar I did this in iOS and able to add gif in tab bar, and I need same gif in android too, this is what I really want, any help would be appriciated

enter image description here


Solution

  • Create custom Toolbar layout like this. And put your gif, title etc here.

    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:popupTheme="@style/AppTheme.PopupOverlay">
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <pl.droidsonroids.gif.GifImageView
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:src="@drawable/src_anim"
               android:background="@drawable/bg_anim"/>
    
            //Other views
    
        </RelativeLayout>
    
    </android.support.v7.widget.Toolbar>