Realize click on the picture to see the larger picture and set the dialog background to be transparent

 LayoutInflater inflater = LayoutInflater.from(context);
 View imgEntryView = inflater.inflate(R.layout.dialog_photo_entry , null ); // load custom layout file
 final AlertDialog dialog = new AlertDialog.Builder(context).create(); 
 ImageView img = (ImageView)imgEntryView.findViewById(R.id.large_image);

// imageDownloader.download("image address",img); // This is for loading network images, it can be your own image setting method
  Glide
         .with(context)
         .load(list.get(index))
         .into(img);
 dialog.setView(imgEntryView); // Customize dialog
  Window win = dialog.getWindow();
  // Be sure to set Background, if not set, the window property setting is invalid
  win.setBackgroundDrawable( new ColorDrawable(Color. TRANSPARENT ));
 dialog.show();
     //Click event of the big picture (click to make him disappear)
  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>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324492903&siteId=291194637