List of usage examples for android.view View getMeasuredWidth
public final int getMeasuredWidth()
From source file:com.aniruddhc.xPlod.ui.widgets.ScrollableTabView.java
private void selectTab(int position) { for (int i = 0, pos = 0; i < mContainer.getChildCount(); i++, pos++) { View tab = mContainer.getChildAt(i); tab.setSelected(pos == position); }//ww w . j a va 2 s .c o m View selectedTab = mContainer.getChildAt(position); final int w = selectedTab.getMeasuredWidth(); final int l = selectedTab.getLeft(); final int x = l - this.getWidth() / 2 + w / 2; smoothScrollTo(x, this.getScrollY()); }
From source file:com.andrew.apolloMod.ui.widgets.ScrollableTabView.java
private void selectTab(int position) { for (int i = 0, pos = 0; i < mContainer.getChildCount(); i++, pos++) { View tab = mContainer.getChildAt(i); tab.setSelected(pos == position); }//from w ww . j a v a 2 s . c o m View selectedTab = mContainer.getChildAt(position); final int w = selectedTab.getMeasuredWidth(); final int l = selectedTab.getLeft(); final int x = l - this.getWidth() / 2 + w / 2; //? 3tab smoothScrollTo(x, this.getScrollY()); if (BuildConfig.DEBUG) { Log.e(TAG, "smothScrollTo : x =" + x + " this.getScrolly() = " + this.getScrollY()); } }
From source file:com.flexible.flexibleadapter.common.FlexibleItemAnimator.java
private static void clear(View v) { ViewCompat.setAlpha(v, 1);// w ww . j a v a 2 s. co m ViewCompat.setScaleY(v, 1); ViewCompat.setScaleX(v, 1); ViewCompat.setTranslationY(v, 0); ViewCompat.setTranslationX(v, 0); ViewCompat.setRotation(v, 0); ViewCompat.setRotationY(v, 0); ViewCompat.setRotationX(v, 0); ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2); ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2); ViewCompat.animate(v).setInterpolator(null).setStartDelay(0); }
From source file:com.andrew.apollo.ui.widgets.ScrollableTabView.java
private void selectTab(int position) { for (int i = 0, pos = 0; i < mContainer.getChildCount(); i += 2, pos++) { View tab = mContainer.getChildAt(i); tab.setSelected(pos == position); }/*from w w w. j av a 2 s.c o m*/ View selectedTab = mContainer.getChildAt(position * 2); final int w = selectedTab.getMeasuredWidth(); final int l = selectedTab.getLeft(); final int x = l - this.getWidth() / 2 + w / 2; smoothScrollTo(x, this.getScrollY()); }
From source file:android.support.design.internal.BaselineLayout.java
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final int count = getChildCount(); final int parentLeft = getPaddingLeft(); final int parentRight = right - left - getPaddingRight(); final int parentContentWidth = parentRight - parentLeft; final int parentTop = getPaddingTop(); for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (child.getVisibility() == GONE) { continue; }/*from w w w .java 2 s. c o m*/ final int width = child.getMeasuredWidth(); final int height = child.getMeasuredHeight(); final int childLeft = parentLeft + (parentContentWidth - width) / 2; final int childTop; if (mBaseline != -1 && child.getBaseline() != -1) { childTop = parentTop + mBaseline - child.getBaseline(); } else { childTop = parentTop; } child.layout(childLeft, childTop, childLeft + width, childTop + height); } }
From source file:com.manning.androidhacks.hack003.view.CascadeLayout.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int count = getChildCount(); for (int i = 0; i < count; i++) { View child = getChildAt(i); LayoutParams lp = (LayoutParams) child.getLayoutParams(); child.layout(lp.x, lp.y, lp.x + child.getMeasuredWidth(), lp.y + child.getMeasuredHeight()); }/* ww w.j ava 2 s. co m*/ }
From source file:com.ameron32.apps.tapnotes._trial.ui.MultiViewPager.java
protected void onMeasurePage(int widthMeasureSpec, int heightMeasureSpec) { // Only measure if a measurement pass was scheduled if (!mNeedsMeasurePage) { return;/*from w w w . j ava 2 s . com*/ } if (mMatchWidthChildResId == 0) { mNeedsMeasurePage = false; } else if (getChildCount() > 0) { View child = getChildAt(0); child.measure(widthMeasureSpec, heightMeasureSpec); int pageWidth = child.getMeasuredWidth(); View match = child.findViewById(mMatchWidthChildResId); if (match == null) { throw new NullPointerException( "MatchWithChildResId did not find that ID in the first fragment of the ViewPager; " + "is that view defined in the child view's layout? Note that MultiViewPager " + "only measures the child for index 0."); } int childWidth = match.getMeasuredWidth(); // Check that the measurement was successful if (childWidth > 0) { mNeedsMeasurePage = false; int difference = pageWidth - childWidth; setPageMargin(-difference); int offscreen = (int) Math.ceil((float) pageWidth / (float) childWidth) + 1; setOffscreenPageLimit(offscreen); requestLayout(); } } }
From source file:com.eggwall.SoundSleep.SleepActivity.java
/** * Calculates the dimension of the entire window. Safe if called repeatedly. *//*from w w w. jav a 2s . c o m*/ private void populateTopLevelDimen() { if (mWidth == 0) { final View topLevel = findViewById(R.id.toplevel); mWidth = topLevel.getRight(); } if (mHeight == 0) { final View topLevel = findViewById(R.id.toplevel); mHeight = topLevel.getBottom(); } if (cloudSize == null) { final View cloud = findViewById(R.id.cloud); cloudSize = new Pair(cloud.getMeasuredWidth(), cloud.getMeasuredHeight()); } if (noteSize == null) { final View note = findViewById(R.id.note); noteSize = new Pair(note.getMeasuredWidth(), note.getMeasuredHeight()); } }
From source file:com.astuetz.viewpager.extensions.ScrollingTabsView.java
/** * Runs through all tabs and sets if they are currently selected. * * @param position The position of the currently selected tab. *//*from w ww. j a v a2s .c om*/ private void selectTab(int position) { for (int i = 0, pos = 0; i < mContainer.getChildCount(); i += 2, pos++) { View tab = mContainer.getChildAt(i); tab.setSelected(pos == position); } View selectedTab = mContainer.getChildAt(position * 2); if (selectedTab != null) { final int w = selectedTab.getMeasuredWidth(); final int l = selectedTab.getLeft(); final int x = l - this.getWidth() / 2 + w / 2; smoothScrollTo(x, this.getScrollY()); } }
From source file:android.support.v7.internal.widget.AbsActionBarView.java
protected int positionChild(View child, int x, int y, int contentHeight, boolean reverse) { int childWidth = child.getMeasuredWidth(); int childHeight = child.getMeasuredHeight(); int childTop = y + (contentHeight - childHeight) / 2; if (reverse) { child.layout(x - childWidth, childTop, x, childTop + childHeight); } else {//from w w w . j a v a 2 s . c o m child.layout(x, childTop, x + childWidth, childTop + childHeight); } return (reverse ? -childWidth : childWidth); }