//获取屏幕的宽度和高度
WindowManager wm = this.getWindowManager();
int width = wm.getDefaultDisplay().getWidth();
int height = wm.getDefaultDisplay().getHeight();
//gif图片,加载gif图片
gif1=(GifView)findViewById(R.id.gif1);
//设置控件的宽和高
ViewGroup.LayoutParams para;
//设置控件的宽和高
LayoutParams para;
para = gif1.getLayoutParams();
para.width=width;
para.height=heigh;
gif1.setLayoutParams(para);
para.height=height-400;
gif1.setLayoutParams(para);
//设置图片原
gif1.setGifImage(R.drawable.scanning);
//设置显示的大小,拉伸或压缩
gif1.setShowDimension(width,height-400);
//设置加载方式,先加载后显示,边加载边显示,只显示第一帧再显示
gif1.setGifImageType(GifView.GifImageType.COVER);
xml代码
<com.ant.liao.GifView
android:id="@+id/gif1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="@+id/commontitlebar2"/>