List of usage examples for android.view View getLayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams()
From source file:android.support.v7.app.MediaRouteControllerDialog.java
private void updateVolumeGroupItemHeight(View item) { LinearLayout container = (LinearLayout) item.findViewById(R.id.volume_item_container); setLayoutHeight(container, mVolumeGroupListItemHeight); View icon = item.findViewById(R.id.mr_volume_item_icon); ViewGroup.LayoutParams lp = icon.getLayoutParams(); lp.width = mVolumeGroupListItemIconSize; lp.height = mVolumeGroupListItemIconSize; icon.setLayoutParams(lp);//from ww w . ja v a2s . c o m }
From source file:android.car.ui.provider.CarDrawerLayout.java
/** * @return the absolute gravity of the child drawerView, resolved according * to the current layout direction *//*from w w w . j av a 2s . c om*/ private int getDrawerViewAbsoluteGravity(View drawerView) { final int gravity = ((LayoutParams) drawerView.getLayoutParams()).gravity; return GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this)); }
From source file:android.car.ui.provider.CarDrawerLayout.java
private void dispatchOnDrawerClosed(View drawerView) { final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); if (lp.knownOpen) { lp.knownOpen = false;//from w ww .j ava2 s.c om if (mDrawerListener != null) { mDrawerListener.onDrawerClosed(drawerView); } } }
From source file:android.car.ui.provider.CarDrawerLayout.java
private void dispatchOnDrawerOpened(View drawerView) { final LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); if (!lp.knownOpen) { lp.knownOpen = true;//from w w w . j av a 2 s . c om if (mDrawerListener != null) { mDrawerListener.onDrawerOpened(drawerView); } } }
From source file:android.car.ui.provider.CarDrawerLayout.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthMode = MeasureSpec.getMode(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); if (widthMode != MeasureSpec.EXACTLY || heightMode != MeasureSpec.EXACTLY) { if (isInEditMode()) { // Don't crash the layout editor. Consume all of the space if specified // or pick a magic number from thin air otherwise. // TODO Better communication with tools of this bogus state. // It will crash on a real device. if (widthMode == MeasureSpec.UNSPECIFIED) { widthSize = 300;//from w w w . j av a2s . c om } else if (heightMode == MeasureSpec.UNSPECIFIED) { heightSize = 300; } } else { throw new IllegalArgumentException("DrawerLayout must be measured with MeasureSpec.EXACTLY."); } } setMeasuredDimension(widthSize, heightSize); View view = findContentView(); LayoutParams lp = ((LayoutParams) view.getLayoutParams()); // Content views get measured at exactly the layout's size. final int contentWidthSpec = MeasureSpec.makeMeasureSpec(widthSize - lp.leftMargin - lp.rightMargin, MeasureSpec.EXACTLY); final int contentHeightSpec = MeasureSpec.makeMeasureSpec(heightSize - lp.topMargin - lp.bottomMargin, MeasureSpec.EXACTLY); view.measure(contentWidthSpec, contentHeightSpec); view = findDrawerView(); lp = ((LayoutParams) view.getLayoutParams()); final int drawerWidthSpec = getChildMeasureSpec(widthMeasureSpec, lp.leftMargin + lp.rightMargin, lp.width); final int drawerHeightSpec = getChildMeasureSpec(heightMeasureSpec, lp.topMargin + lp.bottomMargin, lp.height); view.measure(drawerWidthSpec, drawerHeightSpec); }
From source file:androidx.mediarouter.app.MediaRouteControllerDialog.java
void updateVolumeGroupItemHeight(View item) { LinearLayout container = (LinearLayout) item.findViewById(R.id.volume_item_container); setLayoutHeight(container, mVolumeGroupListItemHeight); View icon = item.findViewById(R.id.mr_volume_item_icon); ViewGroup.LayoutParams lp = icon.getLayoutParams(); lp.width = mVolumeGroupListItemIconSize; lp.height = mVolumeGroupListItemIconSize; icon.setLayoutParams(lp);//from w ww . j av a2s .c om }
From source file:android.car.ui.provider.CarDrawerLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { mInLayout = true;/*from w ww . j a v a 2 s.c o m*/ final int width = r - l; View contentView = findContentView(); View drawerView = findDrawerView(); LayoutParams drawerLp = (LayoutParams) drawerView.getLayoutParams(); LayoutParams contentLp = (LayoutParams) contentView.getLayoutParams(); int contentRight = contentLp.getMarginStart() + getWidth(); contentView.layout(contentRight - contentView.getMeasuredWidth(), contentLp.topMargin, contentRight, contentLp.topMargin + contentView.getMeasuredHeight()); final int childHeight = drawerView.getMeasuredHeight(); int onScreen = (int) (drawerView.getWidth() * drawerLp.onScreen); int offset; if (checkDrawerViewAbsoluteGravity(drawerView, Gravity.LEFT)) { offset = onScreen - drawerView.getWidth(); } else { offset = width - onScreen; } drawerView.layout(drawerLp.getMarginStart() + offset, drawerLp.topMargin, width - drawerLp.getMarginEnd() + offset, childHeight + drawerLp.topMargin); updateDrawerAlpha(); updateViewFaders(); if (mFirstLayout) { // TODO(b/15394507): Normally, onMeasure()/onLayout() are called three times when // you create CarDrawerLayout, but when you pop it back it's only called once which // leaves us in a weird state. This is a pretty ugly hack to fix that. mHandler.post(mInvalidateRunnable); mFirstLayout = false; } if (mNeedsFocus) { if (initializeFocus()) { mNeedsFocus = false; } } mInLayout = false; }
From source file:android.support.design.widget.AppBarLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); invalidateScrollRanges();//from w w w . j a v a 2s . c o m mHaveChildWithInterpolator = false; for (int i = 0, z = getChildCount(); i < z; i++) { final View child = getChildAt(i); final LayoutParams childLp = (LayoutParams) child.getLayoutParams(); final Interpolator interpolator = childLp.getScrollInterpolator(); if (interpolator != null) { mHaveChildWithInterpolator = true; break; } } updateCollapsible(); }
From source file:be.digitalia.fosdem.widgets.SlidingTabLayout.java
private void populateTabStrip() { final int adapterCount = mAdapter.getCount(); final View.OnClickListener tabClickListener = new TabClickListener(); final LayoutInflater inflater = LayoutInflater.from(getContext()); final int currentItem = mViewPager.getCurrentItem(); for (int i = 0; i < adapterCount; i++) { View tabView; TextView tabTitleView;//from w w w . j a v a2s.co m if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = inflater.inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); if (tabTitleView == null) { tabTitleView = (TextView) tabView; } } else { // Inflate our default tab layout tabView = inflater.inflate(R.layout.widget_sliding_tab_layout_text, mTabStrip, false); tabTitleView = (TextView) tabView; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Emulate Roboto Medium in previous Android versions tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); } } if (mTextColor != null) { tabTitleView.setTextColor(mTextColor); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(mAdapter.getPageTitle(i)); tabView.setFocusable(true); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); if (i == currentItem) { tabView.setSelected(true); } } }
From source file:android.car.ui.provider.CarDrawerLayout.java
private void setDrawerViewOffset(View drawerView, float slideOffset) { if (slideOffset == onScreen()) { return;//from w ww . jav a2 s . co m } LayoutParams lp = (LayoutParams) drawerView.getLayoutParams(); lp.onScreen = slideOffset; dispatchOnDrawerSlide(drawerView, slideOffset); }