List of usage examples for android.support.v4.view MarginLayoutParamsCompat setMarginEnd
public static void setMarginEnd(MarginLayoutParams marginLayoutParams, int i)
From source file:com.github.andrewlord1990.snackbarbuilder.SnackbarIconBuilder.java
private LayoutParams getIconViewLayoutParams() { LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; params.weight = 0;/*from www .j av a2 s . c o m*/ MarginLayoutParamsCompat.setMarginStart(params, iconMarginStartPixels); MarginLayoutParamsCompat.setMarginEnd(params, iconMarginEndPixels); return params; }
From source file:com.google.android.apps.flexbox.FlexItem.java
public FlexboxLayout.LayoutParams toLayoutParams(Context context) { FlexboxLayout.LayoutParams lp = new FlexboxLayout.LayoutParams(Util.dpToPixel(context, width), Util.dpToPixel(context, height)); lp.order = order;/*w w w . ja v a 2 s . c o m*/ lp.flexGrow = flexGrow; lp.flexShrink = flexShrink; lp.alignSelf = alignSelf; lp.flexBasisPercent = flexBasisPercent; lp.topMargin = topMargin; MarginLayoutParamsCompat.setMarginStart(lp, startMargin); MarginLayoutParamsCompat.setMarginEnd(lp, endMargin); lp.bottomMargin = bottomMargin; lp.minWidth = Util.dpToPixel(context, minWidth); lp.minHeight = Util.dpToPixel(context, minHeight); lp.maxWidth = Util.dpToPixel(context, maxWidth); lp.maxHeight = Util.dpToPixel(context, maxHeight); lp.wrapBefore = wrapBefore; return lp; }
From source file:sg.fxl.topeka.widget.quiz.AbsQuizView.java
private void addFloatingActionButton() { final int fabSize = getResources().getDimensionPixelSize(R.dimen.size_fab); int bottomOfQuestionView = findViewById(R.id.question_view).getBottom(); final LayoutParams fabLayoutParams = new LayoutParams(fabSize, fabSize, Gravity.END | Gravity.TOP); final int halfAFab = fabSize / 2; fabLayoutParams.setMargins(0, // left bottomOfQuestionView - halfAFab, //top 0, // right spacingDouble); // bottom MarginLayoutParamsCompat.setMarginEnd(fabLayoutParams, spacingDouble); if (ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) { // Account for the fab's emulated shadow. fabLayoutParams.topMargin -= (submitAnswer.getPaddingTop() / 2); }//w w w .ja v a 2 s .c o m addView(submitAnswer, fabLayoutParams); }
From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java
private void addFloatingActionButton() { final int fabSize = getResources().getDimensionPixelSize(R.dimen.size_fab); int bottomOfQuestionView = findViewById(R.id.question_view).getBottom(); final LayoutParams fabLayoutParams = new LayoutParams(fabSize, fabSize, Gravity.END | Gravity.TOP); final int halfAFab = fabSize / 2; fabLayoutParams.setMargins(0, // left bottomOfQuestionView - halfAFab, //top 0, // right mSpacingDouble); // bottom MarginLayoutParamsCompat.setMarginEnd(fabLayoutParams, mSpacingDouble); if (ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) { // Account for the fab's emulated shadow. fabLayoutParams.topMargin -= (mSubmitAnswer.getPaddingTop() / 2); }//from w ww . j a v a2 s . co m addView(mSubmitAnswer, fabLayoutParams); }
From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java
private void applyXmlAttributes(AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingSearchView, defStyleAttr, defStyleRes);/*ww w . ja v a 2 s.com*/ // Search bar width View suggestionsContainer = findViewById(R.id.fsv_suggestions_container); int searchBarWidth = a.getDimensionPixelSize(R.styleable.FloatingSearchView_fsv_searchBarWidth, searchContainer.getLayoutParams().width); searchContainer.getLayoutParams().width = searchBarWidth; suggestionsContainer.getLayoutParams().width = searchBarWidth; // Divider ViewUtils.setBackground(divider, a.getDrawable(R.styleable.FloatingSearchView_android_divider)); int dividerHeight = a.getDimensionPixelSize(R.styleable.FloatingSearchView_android_dividerHeight, -1); MarginLayoutParams dividerLP = (MarginLayoutParams) divider.getLayoutParams(); if (divider.getBackground() != null && dividerHeight != -1) dividerLP.height = dividerHeight; float maxShadowSize = searchBackground.getMaxShadowSize(); float cornerRadius = searchBackground.getCornerRadius(); int horizontalPadding = (int) (RoundRectDrawableWithShadow.calculateHorizontalPadding(maxShadowSize, cornerRadius, false) + .5f); dividerLP.setMargins(horizontalPadding, dividerLP.topMargin, horizontalPadding, dividerLP.bottomMargin); divider.setLayoutParams(dividerLP); // Content inset MarginLayoutParams searchParams = (MarginLayoutParams) searchInput.getLayoutParams(); int contentInsetStart = a.getDimensionPixelSize(R.styleable.FloatingSearchView_contentInsetStart, MarginLayoutParamsCompat.getMarginStart(searchParams)); int contentInsetEnd = a.getDimensionPixelSize(R.styleable.FloatingSearchView_contentInsetEnd, MarginLayoutParamsCompat.getMarginEnd(searchParams)); MarginLayoutParamsCompat.setMarginStart(searchParams, contentInsetStart); MarginLayoutParamsCompat.setMarginEnd(searchParams, contentInsetEnd); // anything else setLogo(a.getDrawable(R.styleable.FloatingSearchView_logo)); setContentBackgroundColor( a.getColor(R.styleable.FloatingSearchView_fsv_contentBackgroundColor, DEFAULT_CONTENT_COLOR)); setRadius(a.getDimensionPixelSize(R.styleable.FloatingSearchView_fsv_cornerRadius, ViewUtils.dpToPx(DEFAULT_RADIUS))); inflateMenu(a.getResourceId(R.styleable.FloatingSearchView_fsv_menu, 0)); setPopupTheme(a.getResourceId(R.styleable.FloatingSearchView_popupTheme, 0)); setHint(a.getString(R.styleable.FloatingSearchView_android_hint)); setIcon(a.getDrawable(R.styleable.FloatingSearchView_fsv_icon)); a.recycle(); }
From source file:co.carlosjimenez.android.currencyalerts.app.MainActivityFragment.java
/** * Method to set the position of the FAB button according to the material design guidelines. *//*from w w w. j a v a2 s. c o m*/ private void addFloatingActionButton() { final int fabSize = getResources().getDimensionPixelSize(R.dimen.size_fab); final int spacingDouble = getResources().getDimensionPixelSize(R.dimen.spacing_double); int bottomOfToolbar = mAppBarLayout.getBottom(); final CoordinatorLayout.LayoutParams fabLayoutParams = new CoordinatorLayout.LayoutParams(fabSize, fabSize); fabLayoutParams.gravity = Gravity.END | Gravity.TOP; final int halfAFab = fabSize / 2; fabLayoutParams.setMargins(0, // left bottomOfToolbar - halfAFab, //top 0, // right spacingDouble); // bottom MarginLayoutParamsCompat.setMarginEnd(fabLayoutParams, spacingDouble); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Account for the fab's emulated shadow. fabLayoutParams.topMargin -= (mCalculateButton.getPaddingTop() / 2); } mCoordinatorLayout.addView(mCalculateButton, fabLayoutParams); }