List of usage examples for android.view Window setGravity
public void setGravity(int gravity)
From source file:com.fbartnitzek.tasteemall.filter.AttributeFilterBaseDialogFragment.java
@NonNull @Override/* www . j a va 2 s. com*/ public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); Bundle bundle = getArguments(); if (bundle == null) { bundle = savedInstanceState; } if (bundle == null) { throw new RuntimeException("neither args nor savedInstance - should never happen..."); } mBaseEntity = bundle.getString(BASE_ENTITY); mAttributeName = bundle.getString(ATTRIBUTE_NAME); // nothing really works to restrict the size => TODO Window window = dialog.getWindow(); if (window != null) { window.setGravity(Gravity.CENTER); // dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); // WindowManager.LayoutParams p = window.getAttributes(); // Log.v(LOG_TAG, "onCreateDialog, p.verticalMargin=" + p.verticalMargin + ", " + "p.horizontalMargin = [" + p.horizontalMargin+ "]"); // p.height = getActivity().getResources().getDisplayMetrics().heightPixels / 2; // float vertMargin = p.verticalMargin; // p.verticalMargin = vertMargin + dpToPx(100); // p.y = prevY + dpToPx(100); // p.x = 150; // window.setAttributes(p); // fullscreen: height and width = -1 // Log.v(LOG_TAG, "onCreateDialog, p.width=" + p.width + ", " + "p.height = [" + p.height+ "]"); } return dialog; }
From source file:com.visenze.visearch.camerademo.fragments.ImageFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window window = getActivity().getWindow(); window.setLayout(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); window.setGravity(Gravity.CENTER); setStyle(android.support.v4.app.DialogFragment.STYLE_NO_TITLE, R.style.Theme_TransparentDark); //get parameters url = (String) getArguments().get("url"); }
From source file:de.grobox.liberario.fragments.HomePickerDialogFragment.java
@Override public void onResume() { // set width to match parent Window window = getDialog().getWindow(); window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.CENTER); super.onResume(); }
From source file:fragments.NewTicket.java
@Override public void onResume() { super.onResume(); Window window = getDialog().getWindow(); window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); window.setGravity(Gravity.CENTER); }
From source file:de.grobox.transportr.favorites.locations.SpecialLocationFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getDialog().setCanceledOnTouchOutside(true); // set width to match parent and show keyboard Window window = getDialog().getWindow(); if (window != null) { window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.TOP); window.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); }// www. jav a2 s . c o m }
From source file:de.grobox.liberario.favorites.trips.SpecialLocationFragment.java
@Override public void onResume() { super.onResume(); getDialog().setCanceledOnTouchOutside(true); // set width to match parent Window window = getDialog().getWindow(); if (window != null) { window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.TOP); }/*from w ww. j av a 2s .c o m*/ InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(loc, InputMethodManager.SHOW_FORCED); }
From source file:com.orange.ocara.ui.dialog.AudioPlayerDialog.java
@Override public void onStart() { super.onStart(); // safety check if (getDialog() == null) return;//from www. j a v a 2 s. c o m // set dialog width Window window = getDialog().getWindow(); // set "origin" to top left corner window.setGravity(Gravity.TOP); //| Gravity.LEFT); int width = getResources().getDimensionPixelSize(R.dimen.audioPlayerDialogWidth); window.setLayout(width, WindowManager.LayoutParams.WRAP_CONTENT); WindowManager.LayoutParams attributes = window.getAttributes(); Integer argX = getArguments().getInt("x"); Integer argY = getArguments().getInt("y"); if (argX != null && argX >= 0) { attributes.x = argX; } if (argY != null && argY >= 0) { attributes.y = argY; } window.setAttributes(attributes); }
From source file:com.ovrhere.android.careerstack.ui.fragments.dialogs.SearchBarDialogFragment.java
/** Initializes the dialogs animations and dim. */ private void initAnimationAndDim() { Window win = getDialog().getWindow(); win.setGravity(Gravity.TOP); win.setWindowAnimations(R.style.SearchBarAnimation); WindowManager.LayoutParams lp = win.getAttributes(); lp.dimAmount = 0.3f; //TODO abstract? is it necessary? win.setAttributes(lp);//from w w w . ja v a 2s . co m win.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); }
From source file:com.github.piasy.chatrecyclerview.example.InputDialog.java
@Override public void onStart() { super.onStart(); // without title and title divider // Less dimmed background; see http://stackoverflow.com/q/13822842/56285 Window window = getDialog().getWindow(); WindowManager.LayoutParams params = window.getAttributes(); //CHECKSTYLE:OFF params.dimAmount = 0;/* w ww .j av a 2 s. co m*/ //CHECKSTYLE:ON window.setAttributes(params); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); window.setGravity(Gravity.BOTTOM); // Transparent background; see http://stackoverflow.com/q/15007272/56285 // (Needed to make dialog's alpha shadow look good) window.setBackgroundDrawableResource(android.R.color.transparent); final Resources res = getResources(); final int titleDividerId = res.getIdentifier("titleDivider", "id", "android"); if (titleDividerId > 0) { final View titleDivider = getDialog().findViewById(titleDividerId); if (titleDivider != null) { titleDivider.setBackgroundColor(res.getColor(android.R.color.transparent)); } } }
From source file:org.catrobat.catroid.ui.dialogs.AddBrickDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.dialog_brick_add, null); ImageButton closeButton = (ImageButton) rootView.findViewById(R.id.dialog_brick_title_button_close); TextView textView = (TextView) rootView.findViewById(R.id.dialog_brick_title_text_view_title); listView = (ListView) rootView.findViewById(R.id.dialog_brick_add_list_view); closeButton.setOnClickListener(new View.OnClickListener() { @Override// w w w . j a va2 s. co m public void onClick(View v) { dismiss(); } }); textView.setText(selectedCategory); Window window = getDialog().getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); window.setGravity(Gravity.CENTER | Gravity.FILL_HORIZONTAL | Gravity.FILL_VERTICAL); window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); return rootView; }