Reputation: 39564
I have a simple request: I have to put some pictures (some small resolution, some big resolution) in a dialog and display them fullscreen.
I tried this:
Dialog dialog = new Dialog(getActivity());
dialog.setContentView(R.layout.custom_dialog);
int picId = Integer.valueOf(webcamCursor.getString(webcamCursor
.getColumnIndex("_id")));
dialog.setTitle(webcamCursor.getString(webcamCursor
.getColumnIndex("City")));
image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.icon);
new DownloadPicTask().execute(Snippets.getUrlFromCat(picId, cat));
dialog.show();
And my layout is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
>
<ImageView android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
/>
</LinearLayout>
As I wrote fill_parent everywhere, shouldn't the dialog take the full screen?
Upvotes: 3
Views: 6532
Reputation: 1441
try this will work
//Grab the window of the dialog, and change the width
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
Window window = dialog.getWindow();
lp.copyFrom(window.getAttributes());
//This makes the dialog take up the full width
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(lp);
Upvotes: 0
Reputation: 3483
Try that:
dialog.getWindow().getAttributes().width = LayoutParams.FILL_PARENT;
Hope it helps.
Upvotes: 8