android - Issue with GIF image -


so using gif in app . when install app in other device gif doesn't fit in screen or it's not on place should be. have solution ?

class:

 package com.example.cyril.tryapp;      import android.content.context;     import android.graphics.canvas;     import android.graphics.movie;     import android.util.attributeset;     import android.view.view;  import java.io.inputstream;  public class gifview extends view {      private inputstream gifinputstream;     private movie gifmovie;     private int moviewidth = 150, movieheight = 500;     private long movieduration;     private long mmoviestart;      public gifview(context context) {         super(context);         init(context);     }      public gifview(context context, attributeset attrs) {         super(context, attrs);         init(context);     }      public gifview(context context, attributeset attrs,                    int defstyleattr) {         super(context, attrs, defstyleattr);         init(context);     }      private void init(context context){         setfocusable(true);         gifinputstream = context.getresources()                 .openrawresource(r.drawable.maestragif);          gifmovie = movie.decodestream(gifinputstream);         moviewidth = gifmovie.width();         movieheight = gifmovie.height();         movieduration = gifmovie.duration();     }      @override     protected void onmeasure(int widthmeasurespec,              int heightmeasurespec) {         setmeasureddimension(moviewidth, movieheight);     }      public int getmoviewidth(){         return moviewidth;     }      public int getmovieheight(){         return movieheight;     }      public long getmovieduration(){         return movieduration;     }      @override     protected void ondraw(canvas canvas) {          long = android.os.systemclock.uptimemillis();         if (mmoviestart == 0) {   // first time             mmoviestart = now;         }          if (gifmovie != null) {              int dur = gifmovie.duration();             if (dur == 0) {                 dur = 1000;             }              int reltime = (int)((now - mmoviestart) % dur);              gifmovie.settime(reltime);              gifmovie.draw(canvas, 0, 0);             invalidate();          }      }  } 

xml:

   <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@drawable/bg_mainplain"     android:layout_gravity="center">    <com.example.cyril.tryapp.gifview         android:id="@+id/gifview"         android:layout_width="130dp"         android:layout_height="230dp"         android:layout_alignparentbottom="true"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true"         android:layout_marginbottom="30dp" />      <com.example.cyril.tryapp.gifview2         android:id="@+id/gifview2"         android:layout_width="350dp"         android:layout_height="70dp"         android:layout_alignparenttop="true"         android:layout_centerhorizontal="true" />   </relativelayout> 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -