Display disp = getWindowManager().getDefaultDisplay();
dispWidth = disp.getWidth();
dispHeight = disp.getHeight();
LayoutInflater inflater
= LayoutInflater.from(MainActivity.this);
view1 = inflater.inflate(R.layout.image, null);
ImageView imageView = (ImageView) view1.findViewById(R.id.imageView1);
imageView.setImageBitmap(image0);
imageView.setScaleType(ScaleType.CENTER_CROP);
Builder builder = new AlertDialog.Builder(MainActivity.this)
.setTitle(map.get("src").toString())
.setIcon(null)
.setView(view1)
.setPositiveButton(
"Ok",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setNegativeButton(
"Close",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog dialog_play = builder.create();
WindowManager.LayoutParams wmlp=dialog_play.getWindow().getAttributes();
wmlp.width=(int) Math.round(dispWidth*0.8);
wmlp.height=(int) Math.round(dispHeight*0.8);
wmlp.gravity=Gravity.CENTER;
dialog_play.getWindow().setAttributes(wmlp);
dialog_play.show();
レイアウト
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:gravity="left"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="20dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="20dp" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/blank1" />
<LinearLayout
android:id="@+id/main_audio_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>