android.view.ViewGroup.MarginLayoutParams Java Examples
The following examples show how to use
android.view.ViewGroup.MarginLayoutParams.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginActivity.java From ToDoList with Apache License 2.0 | 7 votes |
/** * 恢复初始状态 */ private void recovery() { progress.setVisibility(View.GONE); mBtnLogin.setVisibility(View.VISIBLE); mInputLayout.setVisibility(View.VISIBLE); mName.setVisibility(View.VISIBLE); mPsw.setVisibility(View.VISIBLE); ViewGroup.MarginLayoutParams params = (MarginLayoutParams) mInputLayout.getLayoutParams(); params.leftMargin = 0; params.rightMargin = 0; mInputLayout.setLayoutParams(params); ObjectAnimator animator2 = ObjectAnimator.ofFloat(mInputLayout, "scaleX", 0.5f,1f ); animator2.setDuration(500); animator2.setInterpolator(new AccelerateDecelerateInterpolator()); animator2.start(); }
Example #2
Source File: BatteryBarView.java From GravityBox with Apache License 2.0 | 6 votes |
private void updatePosition() { MarginLayoutParams lp = null; if (mContainerType == ContainerType.STATUSBAR) { lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mHeightPx); ((FrameLayout.LayoutParams)lp).gravity = mPosition == Position.TOP ? Gravity.TOP : Gravity.BOTTOM; } else if (mContainerType == ContainerType.KEYGUARD) { lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, mHeightPx); if (mPosition == Position.TOP) { ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); } else { ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); } } if (lp != null) { lp.setMargins(0, mPosition == Position.TOP ? mMarginPx : 0, 0, mPosition == Position.BOTTOM ? mMarginPx : 0); setLayoutParams(lp); } }
Example #3
Source File: MarginAnimation.java From EverMemo with MIT License | 6 votes |
public MarginAnimation(ViewGroup target, int finalLeft, int finalTop, int finalRight, int finalBottom) { this.finalBottom = finalBottom; this.finalTop = finalTop; this.finalRight = finalRight; this.finalLeft = finalLeft; originLayoutParams = (MarginLayoutParams) target.getLayoutParams(); originBottom = originLayoutParams.bottomMargin; originLeft = originLayoutParams.leftMargin; originRight = originLayoutParams.rightMargin; originTop = originLayoutParams.topMargin; spanLeft = originLeft - this.finalLeft; spanRight = originRight - this.finalRight; spanBottom = originBottom - this.finalBottom; spanTop = originTop - this.finalTop; mTarget = target; setDuration(250); }
Example #4
Source File: SnackbarView.java From AndroidChromium with Apache License 2.0 | 6 votes |
void adjustViewPosition() { mParent.getWindowVisibleDisplayFrame(mCurrentVisibleRect); // Only update if the visible frame has changed, otherwise there will be a layout loop. if (!mCurrentVisibleRect.equals(mPreviousVisibleRect)) { mPreviousVisibleRect.set(mCurrentVisibleRect); int keyboardHeight = mParent.getHeight() - mCurrentVisibleRect.bottom + mCurrentVisibleRect.top; MarginLayoutParams lp = getLayoutParams(); lp.bottomMargin = keyboardHeight; if (mIsTablet) { int margin = mParent.getResources() .getDimensionPixelSize(R.dimen.snackbar_margin_tablet); ApiCompatibilityUtils.setMarginStart(lp, margin); lp.bottomMargin += margin; int width = mParent.getResources() .getDimensionPixelSize(R.dimen.snackbar_width_tablet); lp.width = Math.min(width, mParent.getWidth() - 2 * margin); } mView.setLayoutParams(lp); } }
Example #5
Source File: ViewHighlightOverlays.java From stetho with MIT License | 6 votes |
void highlightView(View view) { ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams instanceof MarginLayoutParams) { MarginLayoutParams marginLayoutParams = (MarginLayoutParams) layoutParams; mMargins.left = marginLayoutParams.leftMargin; mMargins.top = marginLayoutParams.topMargin; mMargins.right = marginLayoutParams.rightMargin; mMargins.bottom = marginLayoutParams.bottomMargin; } else { mMargins.left = 0; mMargins.top = 0; mMargins.right = 0; mMargins.bottom = 0; } mPaddings.left = view.getPaddingLeft(); mPaddings.top = view.getPaddingTop(); mPaddings.right = view.getPaddingRight(); mPaddings.bottom = view.getPaddingBottom(); }
Example #6
Source File: MyRandomSeeFragment.java From letv with Apache License 2.0 | 6 votes |
private void findView() { this.mOperationBarView = this.root.findViewById(2131362660); this.mFooterLayout = UIs.inflate(this.mActivity, R.layout.fragment_my_download_worldcup_bottom, null); this.mFootCloseBtn = (Button) this.mFooterLayout.findViewById(R.id.btn_close_worldcup); this.mNullScrollView = (ScrollView) this.root.findViewById(R.id.scrollview_tip); this.mNullTip = (LinearLayout) this.root.findViewById(R.id.linearlayout_tip_download); this.mTextOpenTip = (TextView) this.root.findViewById(R.id.textv_open_worldcup_tip); ((MarginLayoutParams) this.mTextOpenTip.getLayoutParams()).topMargin = UIs.zoomWidth(LiveType.PLAY_LIVE_OTHER); this.mTextOpenSubTip = (TextView) this.root.findViewById(R.id.textv_open_worldcup_tip_line2); ((MarginLayoutParams) this.mTextOpenSubTip.getLayoutParams()).topMargin = UIs.zoomWidth(9); this.mListView = (ListView) this.root.findViewById(2131361938); this.mStartAllBtn = (Button) this.mOperationBarView.findViewById(2131362659); this.mPauseAllBtn = (Button) this.mOperationBarView.findViewById(2131362658); this.mOpenWorldCupBtn = (Button) this.root.findViewById(R.id.btn_open_close); this.mStartAllBtn.setOnClickListener(this.onClick); this.mPauseAllBtn.setOnClickListener(this.onClick); this.mOpenWorldCupBtn.setOnClickListener(this.onClick); this.mFootCloseBtn.setOnClickListener(this.onClick); this.mDialog = new CustomLoadingDialog(this.mActivity); this.mDialog.setCanceledOnTouchOutside(false); this.rootWatchAlertLayout = (RelativeLayout) this.root.findViewById(R.id.road_watch_ball_alert_layout); ((TextView) this.rootWatchAlertLayout.findViewById(R.id.road_watch_ball_alert)).setText(LetvTools.getTextFromServer(DialogMsgConstantId.CONSTANT_70013, getActivity().getResources().getString(2131100080))); this.rootWatchAlertLayout.setOnClickListener(this.onClick); setText(); }
Example #7
Source File: GlidePagerFragment.java From glide-support with The Unlicense | 6 votes |
@Override public @Nullable View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewPager view = new ViewPager(getActivity()); // container.getContext() results in white on white text view.setId(android.R.id.list); view.setLayoutParams(new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); PagerTitleStrip title = new PagerTabStrip(view.getContext()); ViewPager.LayoutParams params = new ViewPager.LayoutParams(); params.width = LayoutParams.MATCH_PARENT; params.height = LayoutParams.WRAP_CONTENT; params.gravity = Gravity.TOP; title.setLayoutParams(params); view.addView(title); return view; }
Example #8
Source File: ViewHighlightOverlays.java From weex with Apache License 2.0 | 6 votes |
void highlightView(View view) { ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams instanceof MarginLayoutParams) { MarginLayoutParams marginLayoutParams = (MarginLayoutParams) layoutParams; mMargins.left = marginLayoutParams.leftMargin; mMargins.top = marginLayoutParams.topMargin; mMargins.right = marginLayoutParams.rightMargin; mMargins.bottom = marginLayoutParams.bottomMargin; } else { mMargins.left = 0; mMargins.top = 0; mMargins.right = 0; mMargins.bottom = 0; } mPaddings.left = view.getPaddingLeft(); mPaddings.top = view.getPaddingTop(); mPaddings.right = view.getPaddingRight(); mPaddings.bottom = view.getPaddingBottom(); }
Example #9
Source File: BookmarkPage.java From delion with Apache License 2.0 | 6 votes |
/** * Create a new instance of the bookmarks page. * @param activity The activity to get context and manage fragments. * @param tab The tab to load urls. */ public BookmarkPage(Activity activity, Tab tab) { mActivity = activity; mTab = tab; mTitle = activity.getString(R.string.bookmarks); mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(), R.color.default_primary_color); mThemeColor = ApiCompatibilityUtils.getColor( activity.getResources(), R.color.default_primary_color); mManager = new BookmarkManager(mActivity, false); Resources res = mActivity.getResources(); MarginLayoutParams layoutParams = new MarginLayoutParams( MarginLayoutParams.MATCH_PARENT, MarginLayoutParams.MATCH_PARENT); layoutParams.setMargins(0, res.getDimensionPixelSize(R.dimen.tab_strip_height) + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow), 0, 0); mManager.getView().setLayoutParams(layoutParams); mManager.setUrlChangeListener(this); }
Example #10
Source File: MultiColumnListAdapter.java From multi-column-list-adapter with Apache License 2.0 | 5 votes |
/** * Update layout params for grid item view with appropriate vertical spacing since view re-use could change the spacing. */ private void updateGridItemLayoutParams(MultiColumnListViewHolder gridItemViewHolder, int row) { if (gridItemViewHolder != null) { View gridItemView = gridItemViewHolder.getGridItemView(); if (gridItemView != null) { LayoutParams lp = gridItemView.getLayoutParams(); if (lp instanceof MarginLayoutParams) { MarginLayoutParams mlp = (MarginLayoutParams) lp; int numRows = getCount(); mlp.topMargin = (row == 0 ? gridItemVerticalSpacing : gridItemVerticalSpacing / 2); mlp.bottomMargin = (row == numRows - 1 ? gridItemVerticalSpacing : gridItemVerticalSpacing / 2); } } } }
Example #11
Source File: SearchEnginePreference.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mListView = (ListView) getView().findViewById(android.R.id.list); int marginTop = getActivity().getResources().getDimensionPixelSize( R.dimen.search_engine_list_margin_top); MarginLayoutParams layoutParams = (MarginLayoutParams) mListView.getLayoutParams(); layoutParams.setMargins(0, marginTop, 0, 0); mListView.setLayoutParams(layoutParams); mListView.setAdapter(mSearchEngineAdapter); mListView.setDivider(null); }
Example #12
Source File: VenvyUIUtil.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
/** * @param view * @return the MarginLayoutParams of a view. maybe null. */ public static MarginLayoutParams getViewMarginLayoutParams(View view) { ViewGroup.LayoutParams params = null; if (null != view) { params = view.getLayoutParams(); } if (params instanceof MarginLayoutParams) { MarginLayoutParams marginLayoutParams = (MarginLayoutParams) params; return marginLayoutParams; } return null; }
Example #13
Source File: AbViewUtil.java From FimiX8-RE with MIT License | 5 votes |
@SuppressLint({"NewApi"}) public static void scaleView(View view) { if (view instanceof TextView) { TextView textView = (TextView) view; setTextSize(textView, textView.getTextSize()); } LayoutParams params = view.getLayoutParams(); if (params != null) { int width = Integer.MIN_VALUE; int height = Integer.MIN_VALUE; if (!(params.width == -2 || params.width == -1)) { width = params.width; } if (!(params.height == -2 || params.height == -1)) { height = params.height; } setViewSize(view, width, height); setPadding(view, view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom()); } if (view.getLayoutParams() instanceof MarginLayoutParams) { MarginLayoutParams mMarginLayoutParams = (MarginLayoutParams) view.getLayoutParams(); if (mMarginLayoutParams != null) { setMargin(view, mMarginLayoutParams.leftMargin, mMarginLayoutParams.topMargin, mMarginLayoutParams.rightMargin, mMarginLayoutParams.bottomMargin); } } if (VERSION.SDK_INT >= 16) { int minWidth = scaleValue(view.getContext(), (float) view.getMinimumWidth()); int minHeight = scaleValue(view.getContext(), (float) view.getMinimumHeight()); view.setMinimumWidth(minWidth); view.setMinimumHeight(minHeight); } }
Example #14
Source File: PercentLayoutHelper.java From FimiX8-RE with MIT License | 5 votes |
public void adjustChildren(int widthMeasureSpec, int heightMeasureSpec) { if (Log.isLoggable(TAG, 3)) { Log.d(TAG, "adjustChildren: " + this.mHost + " widthMeasureSpec: " + MeasureSpec.toString(widthMeasureSpec) + " heightMeasureSpec: " + MeasureSpec.toString(heightMeasureSpec)); } int widthHint = MeasureSpec.getSize(widthMeasureSpec); int heightHint = MeasureSpec.getSize(heightMeasureSpec); if (Log.isLoggable(TAG, 3)) { Log.d(TAG, "widthHint = " + widthHint + " , heightHint = " + heightHint); } int N = this.mHost.getChildCount(); for (int i = 0; i < N; i++) { View view = this.mHost.getChildAt(i); LayoutParams params = view.getLayoutParams(); if (Log.isLoggable(TAG, 3)) { Log.d(TAG, "should adjust " + view + " " + params); } if (params instanceof PercentLayoutParams) { PercentLayoutInfo info = ((PercentLayoutParams) params).getPercentLayoutInfo(); if (Log.isLoggable(TAG, 3)) { Log.d(TAG, "using " + info); } if (info != null) { supportTextSize(widthHint, heightHint, view, info); supportPadding(widthHint, heightHint, view, info); supportMinOrMaxDimesion(widthHint, heightHint, view, info); if (params instanceof MarginLayoutParams) { info.fillMarginLayoutParams((MarginLayoutParams) params, widthHint, heightHint); } else { info.fillLayoutParams(params, widthHint, heightHint); } } } } }
Example #15
Source File: ViewLayoutUtils.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 5 votes |
public static MarginLayoutParams newLayoutParam(final ViewGroup placer, final int width, final int height) { if (placer instanceof FrameLayout) { return new FrameLayout.LayoutParams(width, height); } else if (placer instanceof RelativeLayout) { return new RelativeLayout.LayoutParams(width, height); } else if (placer == null) { throw new NullPointerException("placer is null"); } else { throw new IllegalArgumentException("placer is neither FrameLayout nor RelativeLayout: " + placer.getClass().getName()); } }
Example #16
Source File: BaseTransientBottomBar.java From material-components-android with Apache License 2.0 | 5 votes |
private int getTranslationYBottom() { int translationY = view.getHeight(); LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams instanceof MarginLayoutParams) { translationY += ((MarginLayoutParams) layoutParams).bottomMargin; } return translationY; }
Example #17
Source File: ViewLayoutUtils.java From openboard with GNU General Public License v3.0 | 5 votes |
public static void placeViewAt(final View view, final int x, final int y, final int w, final int h) { final ViewGroup.LayoutParams lp = view.getLayoutParams(); if (lp instanceof MarginLayoutParams) { final MarginLayoutParams marginLayoutParams = (MarginLayoutParams)lp; marginLayoutParams.width = w; marginLayoutParams.height = h; marginLayoutParams.setMargins(x, y, 0, 0); } }
Example #18
Source File: ApiCompatibilityUtils.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * @see android.view.ViewGroup.MarginLayoutParams#setMarginStart(int) */ public static void setMarginStart(MarginLayoutParams layoutParams, int start) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { layoutParams.setMarginStart(start); } else { layoutParams.leftMargin = start; } }
Example #19
Source File: BarUtils.java From AndroidUtilCode with Apache License 2.0 | 5 votes |
/** * Add the top margin size equals status bar's height for view. * * @param view The view. */ public static void addMarginTopEqualStatusBarHeight(@NonNull View view) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; view.setTag(TAG_OFFSET); Object haveSetOffset = view.getTag(KEY_OFFSET); if (haveSetOffset != null && (Boolean) haveSetOffset) return; MarginLayoutParams layoutParams = (MarginLayoutParams) view.getLayoutParams(); layoutParams.setMargins(layoutParams.leftMargin, layoutParams.topMargin + getStatusBarHeight(), layoutParams.rightMargin, layoutParams.bottomMargin); view.setTag(KEY_OFFSET, true); }
Example #20
Source File: ViewLayoutUtils.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
public static void placeViewAt(final View view, final int x, final int y, final int w, final int h) { final ViewGroup.LayoutParams lp = view.getLayoutParams(); if (lp instanceof MarginLayoutParams) { final MarginLayoutParams marginLayoutParams = (MarginLayoutParams)lp; marginLayoutParams.width = w; marginLayoutParams.height = h; marginLayoutParams.setMargins(x, y, 0, 0); } }
Example #21
Source File: BindingAdapters.java From Jockey with Apache License 2.0 | 5 votes |
@BindingAdapter("android:translationYPercent") public static void bindTranslationYPercent(View view, float percent) { View parent = (View) view.getParent(); MarginLayoutParams layoutParams = (MarginLayoutParams) view.getLayoutParams(); int remainingHeight = parent.getMeasuredHeight() - layoutParams.bottomMargin; view.setTranslationY(-1 * percent * remainingHeight); }
Example #22
Source File: JUIHelper.java From connectivity-samples with Apache License 2.0 | 5 votes |
public void setMargins(final View view, final int left, final int top, final int right, final int bottom) { activity_.runOnUiThread(new Runnable() { @Override public void run() { ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view .getLayoutParams(); params.setMargins(left, top, right, bottom); } }); }
Example #23
Source File: BarUtils.java From AndroidUtilCode with Apache License 2.0 | 5 votes |
/** * Subtract the top margin size equals status bar's height for view. * * @param view The view. */ public static void subtractMarginTopEqualStatusBarHeight(@NonNull View view) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return; Object haveSetOffset = view.getTag(KEY_OFFSET); if (haveSetOffset == null || !(Boolean) haveSetOffset) return; MarginLayoutParams layoutParams = (MarginLayoutParams) view.getLayoutParams(); layoutParams.setMargins(layoutParams.leftMargin, layoutParams.topMargin - getStatusBarHeight(), layoutParams.rightMargin, layoutParams.bottomMargin); view.setTag(KEY_OFFSET, false); }
Example #24
Source File: ApiCompatibilityUtils.java From 365browser with Apache License 2.0 | 5 votes |
/** * @see android.view.ViewGroup.MarginLayoutParams#setMarginStart(int) */ public static void setMarginStart(MarginLayoutParams layoutParams, int start) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { layoutParams.setMarginStart(start); } else { layoutParams.leftMargin = start; } }
Example #25
Source File: ViewLayoutUtils.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
public static void placeViewAt(final View view, final int x, final int y, final int w, final int h) { final ViewGroup.LayoutParams lp = view.getLayoutParams(); if (lp instanceof MarginLayoutParams) { final MarginLayoutParams marginLayoutParams = (MarginLayoutParams)lp; marginLayoutParams.width = w; marginLayoutParams.height = h; marginLayoutParams.setMargins(x, y, 0, 0); } }
Example #26
Source File: MultiPaneActivity.java From MongoExplorer with MIT License | 5 votes |
private void animateFromOffscreenToLeftPane(View view) { ((MarginLayoutParams)view.getLayoutParams()).width = mLeftPaneWidth; view.requestLayout(); Animation animation = new LeftMarginAnimation(view, -mLeftPaneWidth, 0); view.startAnimation(animation); }
Example #27
Source File: PiewController.java From quickmark with MIT License | 5 votes |
public static void setLayoutY(View view, int y) { MarginLayoutParams margin = new MarginLayoutParams( view.getLayoutParams()); margin.setMargins(margin.leftMargin, y, margin.rightMargin, y + margin.height); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( margin); view.setLayoutParams(layoutParams); }
Example #28
Source File: StickyHeaderPositioner.java From StickyHeaders with Apache License 2.0 | 5 votes |
private void matchMarginsToPadding(MarginLayoutParams layoutParams) { @Px int leftMargin = orientation == LinearLayoutManager.VERTICAL ? recyclerView.getPaddingLeft() : 0; @Px int topMargin = orientation == LinearLayoutManager.VERTICAL ? 0 : recyclerView.getPaddingTop(); @Px int rightMargin = orientation == LinearLayoutManager.VERTICAL ? recyclerView.getPaddingRight() : 0; layoutParams.setMargins(leftMargin, topMargin, rightMargin, 0); }
Example #29
Source File: TestFragment.java From glide-support with The Unlicense | 5 votes |
@Override public @Nullable View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RecyclerView view = new RecyclerView(container.getContext()); view.setLayoutParams(new MarginLayoutParams(MATCH_PARENT, MATCH_PARENT)); view.setLayoutManager(new GridLayoutManager(container.getContext(), 2 /*columns*/)); view.setAdapter(new GeneratingAdapter(view.getContext())); return view; }
Example #30
Source File: ProgressBarView.java From GravityBox with Apache License 2.0 | 5 votes |
private void updatePosition() { if (mMode == Mode.OFF) return; MarginLayoutParams lp = null; if (mContainerType == ContainerType.STATUSBAR) { lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mHeightPx); ((FrameLayout.LayoutParams)lp).gravity = mMode == Mode.TOP ? Gravity.TOP : Gravity.BOTTOM; } else if (mContainerType == ContainerType.KEYGUARD) { lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, mHeightPx); if (mMode == Mode.TOP) { ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); } else { ((RelativeLayout.LayoutParams)lp).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); } } if (lp != null) { lp.setMargins(0, mMode == Mode.TOP ? mEdgeMarginPx : 0, 0, mMode == Mode.BOTTOM ? mEdgeMarginPx : 0); setLayoutParams(lp); } }