问题
I have a GridView which show a lot of images and when I click any image it will show full image in a full screen dialog
Please tell me how to do that
thanks.
回答1:
try
Dialog dialog=new Dialog(this,android.R.style.Theme.Black.NoTitleBar.Fullscreen)
回答2:
based on this link , the correct answer (which i've tested myself) is:
put this code in the constructor or the onCreate()
method of the dialog:
getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT);
in addition , set the style of the dialog to :
<style name="full_screen_dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
</style>
this could be achieved via the constructor , for example :
public FullScreenDialog(Context context)
{
super(context, R.style.full_screen_dialog);
...
EDIT: an alternative to all of the above would be to set the style to android.R.style.Theme and that's it.
回答3:
The easiest way I found
Dialog dialog=new Dialog(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
dialog.setContentView(R.layout.frame_help);
dialog.show();
回答4:
EDIT Until such time as StackOverflow allows us to version our answers, this is an answer that works for Android 3 and below. Please don't downvote it because it's not working for you now, because it definitely works with older Android versions.
You should only need to add one line to your onCreateDialog()
method:
@Override
protected Dialog onCreateDialog(int id) {
//all other dialog stuff (which dialog to display)
//this line is what you need:
dialog.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN);
return dialog;
}
回答5:
dialog = new Dialog(getActivity(),android.R.style.Theme_Translucent_NoTitleBar);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.loading_screen);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.CENTER;
wlp.flags &= ~WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
window.setAttributes(wlp);
dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
dialog.show();
try this.
来源:https://stackoverflow.com/questions/6329360/how-to-set-dialog-to-show-with-full-screen