GifImageView
Widht.
init()
{
WindowManager wManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wManager.getDefaultDisplay();
float screenwidth = display.getWidth();
float screenheight = display.getHeight();
mWidth = (int) screenwidth;
mHeight = (int) screenheight;
requestLayout();
}
setGifImageResource() Activity.
:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.myactivity);
GifImageView gifImageView = (GifImageView) findViewById(R.id.GifImageView);
gifImageView.setGifImageResource(R.drawable.my_gif);
}
:
.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(mWidth, mHeight);
}
.
@Override
protected void onDraw(Canvas canvas) {
if (mMovie != null) {
canvas.scale((float) this.getWidth() / (float) mMovie.width(),
(float) this.getHeight() / (float) mMovie.height());
mMovie.draw(canvas, 0, 0);
invalidate();
}
}
.
.
https://github.com/NihalPandya/demoUpload/blob/master/GifImageView.java