Popupwindow with image

后端 未结 1 1772
旧时难觅i
旧时难觅i 2020-12-08 23:57

I need to be able to click an imgview in a listview, which should open a popup showing the image fullsize. I\'ve managed to implement the cli

相关标签:
1条回答
  • 2020-12-09 00:02

    Create custom-dialog and pass image in it....

    private void loadPhoto(ImageView imageView, int width, int height) {
    
            ImageView tempImageView = imageView;
    
    
            AlertDialog.Builder imageDialog = new AlertDialog.Builder(this);
            LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
    
            View layout = inflater.inflate(R.layout.custom_fullimage_dialog,
                    (ViewGroup) findViewById(R.id.layout_root));
            ImageView image = (ImageView) layout.findViewById(R.id.fullimage);
            image.setImageDrawable(tempImageView.getDrawable());
            imageDialog.setView(layout);
            imageDialog.setPositiveButton(resources.getString(R.string.ok_button), new DialogInterface.OnClickListener(){
    
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
    
            });
    
    
            imageDialog.create();
            imageDialog.show();     
        }
    

    custom_fullimage_dialog.xml:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/layout_root" android:orientation="horizontal"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:padding="10dp">
        <ImageView android:id="@+id/fullimage" android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        </ImageView>
    
        <TextView android:id="@+id/custom_fullimage_placename"
            android:layout_width="wrap_content" android:layout_height="fill_parent"
            android:textColor="#FFF">
        </TextView>
    </LinearLayout>
    
    0 讨论(0)
提交回复
热议问题