View inflate = LayoutInflater.from(context).inflate(R.layout.qrcode, null); ImageView qrcode = (ImageView) inflate.findViewById(R.id.iv_qrcode); ImageView guanbi = (ImageView) inflate.findViewById(R.id.iv_guanbi); final Dialog dialog = new AlertDialog .Builder(context) .setView(inflate) .show(); dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); Glide.with(context).load(list.get(position).getDwhat()).into(qrcode); Animation animation = AnimationUtils.loadAnimation(context, R.anim.scale); inflate.setAnimation(animation); animation.start();
最关键的一行代码
布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:id="@+id/iv_qrcode" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@mipmap/ic_launcher" /> <View android:layout_width="match_parent" android:layout_height="80dp" android:background="#00000000" /> <ImageView android:id="@+id/iv_guanbi" android:layout_width="40dp" android:layout_height="40dp" android:background="@android:color/transparent" android:layout_gravity="center" android:src="@drawable/guanbi" /> </LinearLayout>
参考链接:https://blog.csdn.net/aaren_jiang/article/details/12993343
注意:要用Dialog去接收