List of usage examples for android.view View getLayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams()
From source file:com.moods_final.moods.entertainment.VideoListDemoActivity.java
private static void setLayoutSize(View view, int width, int height) { LayoutParams params = view.getLayoutParams(); params.width = width;/* w w w. jav a 2 s . c o m*/ params.height = height; view.setLayoutParams(params); }
From source file:Main.java
/** * Animates a view to the new specified dimensions. * @param view The view to change the dimensions of. * @param newWidth The new width of the view. * @param newHeight The new height of the view. *///from w w w. j a v a2 s .c o m public static void changeDimensions(final View view, final int newWidth, final int newHeight) { ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); final int oldWidth = view.getWidth(); final int oldHeight = view.getHeight(); final int deltaWidth = newWidth - oldWidth; final int deltaHeight = newHeight - oldHeight; animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); view.getLayoutParams().width = (int) (value * deltaWidth + oldWidth); view.getLayoutParams().height = (int) (value * deltaHeight + oldHeight); view.requestLayout(); } }); animator.start(); }
From source file:com.moods_final.moods.entertainment.VideoListDemoActivity.java
private static void setLayoutSizeAndGravity(View view, int width, int height, int gravity) { FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) view.getLayoutParams(); params.width = width;//from ww w . j av a 2 s .c o m params.height = height; params.gravity = gravity; view.setLayoutParams(params); }
From source file:com.actionbarsherlock.internal.view.menu.ActionMenuView.java
/** * Measure a child view to fit within cell-based formatting. The child's width * will be measured to a whole multiple of cellSize. * * <p>Sets the expandable and cellsUsed fields of LayoutParams. * * @param child Child to measure//w w w . ja v a2s . c o m * @param cellSize Size of one cell * @param cellsRemaining Number of cells remaining that this view can expand to fill * @param parentHeightMeasureSpec MeasureSpec used by the parent view * @param parentHeightPadding Padding present in the parent view * @return Number of cells this child was measured to occupy */ static int measureChildForCells(View child, int cellSize, int cellsRemaining, int parentHeightMeasureSpec, int parentHeightPadding) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int childHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec) - parentHeightPadding; final int childHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec); final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, childHeightMode); int cellsUsed = 0; if (cellsRemaining > 0) { final int childWidthSpec = MeasureSpec.makeMeasureSpec(cellSize * cellsRemaining, MeasureSpec.AT_MOST); child.measure(childWidthSpec, childHeightSpec); final int measuredWidth = child.getMeasuredWidth(); cellsUsed = measuredWidth / cellSize; if (measuredWidth % cellSize != 0) cellsUsed++; } final ActionMenuItemView itemView = child instanceof ActionMenuItemView ? (ActionMenuItemView) child : null; final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.hasText(); lp.expandable = expandable; lp.cellsUsed = cellsUsed; final int targetWidth = cellsUsed * cellSize; child.measure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY), childHeightSpec); return cellsUsed; }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Resize a view height and request the re-draw of the view * * @param viewToResize Main Screen Windows to * @param height Amount of pixel can be seeing * @param addValue true increase size else decrease *//* ww w . j ava 2s .c o m*/ private static void resizeViewHeight(View viewToResize, int height, boolean addValue, int realScreenHeight) { if (addValue) { viewToResize.getLayoutParams().height = viewToResize.getHeight() + height; } else { viewToResize.getLayoutParams().height = realScreenHeight - height; } viewToResize.requestLayout(); }
From source file:de.Maxr1998.xposed.maxlock.ui.ThemeService.java
public static ViewGroup.LayoutParams container(final View container, Context context, String lockingType) { loadPrefs(context);//from www . ja v a 2 s. c o m String containerMargin = "container_margin_"; int density = (int) context.getResources().getDisplayMetrics().density; int left = PREFS_THEME.getInt(containerMargin + "left" + "_" + lockingType, 0) * density; int right = PREFS_THEME.getInt(containerMargin + "right" + "_" + lockingType, 0) * density; int top = PREFS_THEME.getInt(containerMargin + "top" + "_" + lockingType, 0) * density; int bottom = PREFS_THEME.getInt(containerMargin + "bottom" + "_" + lockingType, 0) * density; LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(container.getLayoutParams()); layoutParams.setMargins(left, top, right, bottom); layoutParams.weight = 1; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { layoutParams.setMarginStart(left); layoutParams.setMarginEnd(right); } return layoutParams; }
From source file:com.bt.download.android.gui.util.UIUtils.java
/** * This method sets up the visibility of the support frostwire control (@see {@link DonationsView}) * depending on remote configuration parameters and local configuration preferences. * @param supportFrostWireView// w ww . ja va 2s . c o m */ public static void supportFrostWire(View supportFrostWireView) { //remote kill switch if (!ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_GUI_SUPPORT_FROSTWIRE_THRESHOLD)) { supportFrostWireView.setVisibility(View.GONE); Log.v(TAG, "Hiding support, above threshold."); } else if (ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_GUI_SUPPORT_FROSTWIRE)) { supportFrostWireView.setVisibility(View.VISIBLE); if (supportFrostWireView.getLayoutParams() != null) { supportFrostWireView.getLayoutParams().width = LayoutParams.MATCH_PARENT; } } }
From source file:by.vshkl.localweather.ui.DividerItemDecoration.java
public void drawVertical(Canvas c, RecyclerView parent) { // final int left = ((WeatherAdapter) parent.getAdapter()).getItemWidth(); final int left = 0; final int right = parent.getWidth(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int top = child.getBottom() + params.bottomMargin; final int bottom = top + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c);/* w ww . ja va2 s . co m*/ } }
From source file:android.tumb.com.tumb.Misc.DividerItemDecoration.java
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { int left = parent.getPaddingLeft(); int right = parent.getWidth() - parent.getPaddingRight(); int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); int top = child.getBottom() + params.bottomMargin; int bottom = top + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c);/*from w ww . j a v a 2s.c o m*/ } }
From source file:app.iamin.iamin.ui.recyclerview.DividerItemDecoration.java
public void drawVertical(Canvas c, RecyclerView parent) { final int left = parent.getPaddingLeft(); final int right = parent.getWidth() - parent.getPaddingRight(); final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int top = child.getBottom() + params.bottomMargin; final int bottom = top + mDivider.getIntrinsicHeight(); mDivider.setBounds(left, top, right, bottom); mDivider.draw(c);//from w ww . ja v a 2s.com } }