Skip to content

Instantly share code, notes, and snippets.

@pastcompute
Last active April 14, 2018 11:47
Show Gist options
  • Save pastcompute/ee9de32c5abc026928d39707e58407d9 to your computer and use it in GitHub Desktop.
Save pastcompute/ee9de32c5abc026928d39707e58407d9 to your computer and use it in GitHub Desktop.
try {
GifDrawable gif = new GifDrawable( cordova.getActivity().getAssets(), "platfarm.gif" );
GifImageView imageView = new GifImageView(webView.getContext());
imageView.setImageDrawable(gif);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
float density = webView.getContext().getResources().getDisplayMetrics().density;
layoutParams.width = Math.round(230 * density);
layoutParams.height = Math.round(230 * density);
imageView.setLayoutParams(layoutParams);
centeredLayout.addView(imageView);
gif.setSpeed(1);
gif.start();
} catch (IOException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment