I am using Custom AlertDialog.Builder to show Image from SD Card into that alert dialog.
How can I use full width and height of Screen to show dialog, here is my code:
viewHolder.imageButtonView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final AlertDialog.Builder imageDialog = new AlertDialog.Builder(XRayActivity.this);
final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.image_dialog, null);
ImageView image = (ImageView) layout.findViewById(R.id.imageView);
try
{
strFileName = arrayList.get(position).getFilename().toString();
String file = Environment.getExternalStorageDirectory().getPath() + "/Pictures/XRays/" + strFileName;
Bitmap bm = BitmapFactory.decodeFile(file);
image.setScaleType(ImageView.ScaleType.FIT_XY);
image.setImageBitmap(bm);
} catch (Exception e) {
e.printStackTrace();
}
imageDialog.setTitle(strFileName);
imageDialog.setView(layout);
imageDialog.setPositiveButton(android.R.string.ok, new
DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
imageDialog.create();
imageDialog.show();
}
});
image_dialog.xml:-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
In xml I am using only ImageView with match_parent properties of layout_width and layout_height.