Created
March 15, 2016 11:53
-
-
Save IzikAlgrisi/709e7fbc77642f816eee to your computer and use it in GitHub Desktop.
FullScreenFragment also hide the ActionBar if exists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Dialog; | |
import android.graphics.Color; | |
import android.graphics.drawable.ColorDrawable; | |
import android.os.Bundle; | |
import android.support.annotation.Nullable; | |
import android.support.v4.app.DialogFragment; | |
import android.view.Gravity; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.view.Window; | |
import android.view.WindowManager; | |
import android.widget.TextView; | |
/** | |
* Created by dell on 3/15/2016. | |
*/ | |
public class FullScreenDialog extends DialogFragment { | |
@Override | |
public void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme); | |
} | |
@Nullable | |
@Override | |
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
Dialog dialog = getDialog(); | |
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); | |
Window w = dialog.getWindow(); | |
w.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); | |
WindowManager.LayoutParams params = dialog.getWindow().getAttributes(); | |
params.verticalMargin = 0; | |
params.horizontalMargin = 0; | |
params.x=0; | |
params.y = 0; | |
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); | |
params.width= ViewGroup.LayoutParams.MATCH_PARENT; | |
params.height = ViewGroup.LayoutParams.MATCH_PARENT; | |
w.setGravity(Gravity.TOP| Gravity.LEFT); | |
return new TextView(getActivity()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment