实现点击图片看大图以及dialog背景设置透明

 LayoutInflater inflater = LayoutInflater.from(context);
 View imgEntryView = inflater.inflate(R.layout.dialog_photo_entry, null); // 加载自定义的布局文件
 final AlertDialog dialog = new AlertDialog.Builder(context).create();
 ImageView img = (ImageView)imgEntryView.findViewById(R.id.large_image);

// imageDownloader.download("图片地址",img); // 这个是加载网络图片的,可以是自己的图片设置方法
 Glide
         .with(context)
         .load(list.get(index))
         .into(img);
 dialog.setView(imgEntryView); // 自定义dialog
 Window win = dialog.getWindow();
 // 一定要设置Background,如果不设置,window属性设置无效
 win.setBackgroundDrawable( new ColorDrawable(Color.TRANSPARENT));
 dialog.show();
     //大图的点击事件(点击让他消失)
 imgEntryView.setOnClickListener(new View.OnClickListener() {
     public void onClick(View paramView) {
         dialog.cancel();
     }
 });
 



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView android:layout_height="wrap_content"
        android:id="@+id/large_image"
        android:layout_width="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true">
    </ImageView>
</RelativeLayout>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值