Search code examples
javaandroidandroid-imageview

how to show gif on background image in android studio


I want to show Gif as a upper layer on background image. What exactly i want to have image in background and on that image i also want to show gif but when i run the code i am only seeing the gif background image is hidden can someone tell what should i do now

My XML Code is Here

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ice"
tools:context=".MainActivity">

<pl.droidsonroids.gif.GifImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/gif"
    android:background="@drawable/ice"

    /></android.support.constraint.ConstraintLayout>

i have used background image in both GifImage view and also in Layout background but in both case its not showing background.


Solution

  • Why you are seeing GIF Image only, not your background image?

    Because

    1) You are setting "width and height" of your GIF image as "match_parent" hence its 
       taking entire screen and you are not been able to see your background image.
    
    2) Still if you want to set your GIF image as match_parent(that Ok!), make sure you 
       use "alpha GIF image or I would say transparent GIF image"
    

    Note: You can convert your current GIF to transparent GIF online as well.

    Hope this help you somehow.