List of usage examples for android.view Window setLayout
public void setLayout(int width, int height)
From source file:de.mrapp.android.dialog.AbstractMaterialDialogFragment.java
@Override public final void onStart() { super.onStart(); Window window = getDialog().getWindow(); assert window != null; window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); if (showListener != null) { showListener.onShow(getDialog()); }/*from w ww.j a v a 2s. com*/ }
From source file:net.momodalo.app.vimtouch.VimTouch.java
public void showCmdHistory() { final Dialog dialog = new Dialog(this, R.style.DialogSlideAnim); // Setting dialogview Window window = dialog.getWindow(); window.setGravity(Gravity.BOTTOM);//w w w. ja va 2s.com window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); dialog.setTitle(null); dialog.setContentView(R.layout.hist_list); dialog.setCancelable(true); LinearLayout layout = (LinearLayout) dialog.findViewById(R.id.hist_layout); if (AndroidCompat.SDK >= 11) { layout.setShowDividers(LinearLayout.SHOW_DIVIDER_BEGINNING | LinearLayout.SHOW_DIVIDER_MIDDLE | LinearLayout.SHOW_DIVIDER_END); } LayoutParams params = layout.getLayoutParams(); params.width = mScreenWidth; layout.setLayoutParams(params); LayoutInflater inflater = LayoutInflater.from(this); boolean exists = false; for (int i = 1; i <= 10; i++) { TextView button = (TextView) inflater.inflate(R.layout.histbutton, layout, false); String cmd = Exec.getCmdHistory(i); if (cmd.length() == 0) break; exists = true; button.setText(":" + cmd); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TextView text = (TextView) v; CharSequence cmd = text.getText(); Exec.doCommand(cmd.subSequence(1, cmd.length()).toString()); dialog.dismiss(); } }); layout.addView((View) button); } if (exists) dialog.show(); }
From source file:org.chromium.chrome.browser.payments.ui.PaymentRequestUI.java
/** * Builds the UI for PaymentRequest./*from ww w . ja v a 2 s.co m*/ * * @param activity The activity on top of which the UI should be displayed. * @param client The consumer of the PaymentRequest UI. * @param requestShipping Whether the UI should show the shipping address and option selection. * @param requestContact Whether the UI should show the email address and phone number * selection. * @param canAddCards Whether the UI should show the [+ADD CARD] button. This can be false, * for example, when the merchant does not accept credit cards, so * there's no point in adding cards within PaymentRequest UI. * @param title The title to show at the top of the UI. This can be, for example, the * <title> of the merchant website. If the string is too long for * UI, it elides at the end. * @param origin The origin (part of URL) to show under the title. For example, * "https://shop.momandpop.com". If the origin is too long for the UI, it * should elide according to: * https://www.chromium.org/Home/chromium-security/enamel#TOC-Eliding-Origin-Names-And-Hostnames */ public PaymentRequestUI(Activity activity, Client client, boolean requestShipping, boolean requestContact, boolean canAddCards, String title, String origin) { mContext = activity; mClient = client; mRequestShipping = requestShipping; mRequestContactDetails = requestContact; mAnimatorTranslation = activity.getResources().getDimensionPixelSize(R.dimen.payments_ui_translation); mErrorView = (PaymentRequestUiErrorView) LayoutInflater.from(mContext) .inflate(R.layout.payment_request_error, null); mErrorView.initialize(title, origin); mReadyToPayNotifierForTest = new NotifierForTest(new Runnable() { @Override public void run() { if (sObserverForTest != null && isAcceptingUserInput() && mPayButton.isEnabled()) { sObserverForTest.onPaymentRequestReadyToPay(PaymentRequestUI.this); } } }); // This callback will be fired if mIsClientCheckingSelection is true. mUpdateSectionsCallback = new Callback<PaymentInformation>() { @Override public void onResult(PaymentInformation result) { mIsClientCheckingSelection = false; updateOrderSummarySection(result.getShoppingCart()); if (mRequestShipping) { updateSection(TYPE_SHIPPING_ADDRESSES, result.getShippingAddresses()); updateSection(TYPE_SHIPPING_OPTIONS, result.getShippingOptions()); } if (mRequestContactDetails) { updateSection(TYPE_CONTACT_DETAILS, result.getContactDetails()); } updateSection(TYPE_PAYMENT_METHODS, result.getPaymentMethods()); if (mShippingAddressSectionInformation.getSelectedItem() == null) { expand(mShippingAddressSection); } else { expand(null); } updatePayButtonEnabled(); notifySelectionChecked(); } }; mRequestView = (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.payment_request, null); prepareRequestView(activity, title, origin, canAddCards); // To handle the specced animations, the dialog is entirely contained within a translucent // FrameLayout. This could eventually be converted to a real BottomSheetDialog, but that // requires exploration of how interactions would work when the dialog can be sent back and // forth between the peeking and expanded state. mFullContainer = new FrameLayout(mContext); mFullContainer.setBackgroundColor( ApiCompatibilityUtils.getColor(mContext.getResources(), R.color.payments_ui_scrim)); FrameLayout.LayoutParams bottomSheetParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); bottomSheetParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; mFullContainer.addView(mRequestView, bottomSheetParams); mEditorView = new EditorView(activity, sObserverForTest); mCardEditorView = new EditorView(activity, sObserverForTest); // Set up the dialog. mDialog = new AlwaysDismissedDialog(activity, R.style.DialogWhenLarge); mDialog.setOnDismissListener(this); mDialog.addContentView(mFullContainer, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); Window dialogWindow = mDialog.getWindow(); dialogWindow.setGravity(Gravity.CENTER); dialogWindow.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); dialogWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); }