List of usage examples for android.view View getLeft
@ViewDebug.CapturedViewProperty public final int getLeft()
From source file:com.benefit.buy.library.viewpagerindicator.IconPageIndicator.java
private void animateToIcon(final int position) { final View iconView = mIconsLayout.getChildAt(position); if (mIconSelector != null) { removeCallbacks(mIconSelector);//from www.j av a 2 s. c om } mIconSelector = new Runnable() { @Override public void run() { final int scrollPos = iconView.getLeft() - ((getWidth() - iconView.getWidth()) / 2); smoothScrollTo(scrollPos, 0); mIconSelector = null; } }; post(mIconSelector); }
From source file:com.app.learn.Util.SlidingTabLayout.java
private void scrollToTab(int tabIndex, int positionOffset) { final int tabStripChildCount = mTabStrip.getChildCount(); if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) { return;// w w w. j av a2 s.co m } View selectedChild = mTabStrip.getChildAt(tabIndex); if (selectedChild != null) { int targetScrollX = selectedChild.getLeft() + positionOffset; if (tabIndex > 0 || positionOffset > 0) { // If we're not at the first child and are mid-scroll, make sure we obey the offset targetScrollX -= mTitleOffset; } /** * ? tab ?? */ // TextView textView_2; // TextView textView_1 = (TextView) selectedChild; // for(int i = 0; i < tabStripChildCount; i ++) { // if (i == tabIndex) { // textView_1.setTextColor(Color.WHITE); // } // else { // textView_2 = (TextView) mTabStrip.getChildAt(i); // textView_2.setTextColor(Color.LTGRAY); // } // } scrollTo(targetScrollX, 0); } }
From source file:com.android.contacts.common.list.ViewPagerTabs.java
@Override public void onPageSelected(int position) { position = getRtlPosition(position); int tabStripChildCount = mTabStrip.getChildCount(); if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) { return;//from www . ja v a2 s. c o m } if (mPrevSelected >= 0 && mPrevSelected < tabStripChildCount) { mTabStrip.getChildAt(mPrevSelected).setSelected(false); } final View selectedChild = mTabStrip.getChildAt(position); selectedChild.setSelected(true); // Update scroll position final int scrollPos = selectedChild.getLeft() - (getWidth() - selectedChild.getWidth()) / 2; smoothScrollTo(scrollPos, 0); mPrevSelected = position; }
From source file:android.support.v7.internal.widget.ListViewCompat.java
protected void positionSelectorCompat(int position, View sel) { final Rect selectorRect = mSelectorRect; selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(), sel.getBottom()); // Adjust for selection padding. selectorRect.left -= mSelectionLeftPadding; selectorRect.top -= mSelectionTopPadding; selectorRect.right += mSelectionRightPadding; selectorRect.bottom += mSelectionBottomPadding; try {/*from w ww . j a v a2 s . c om*/ // AbsListView.mIsChildViewEnabled controls the selector's state so we need to // modify it's value final boolean isChildViewEnabled = mIsChildViewEnabled.getBoolean(this); if (sel.isEnabled() != isChildViewEnabled) { mIsChildViewEnabled.set(this, !isChildViewEnabled); if (position != INVALID_POSITION) { refreshDrawableState(); } } } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:br.com.cast.treinamento.tabs.SlidingTabLayout.java
private void scrollToTab(int tabIndex, int positionOffset) { final int tabStripChildCount = mTabStrip.getChildCount(); if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) { return;/*ww w . j a v a 2s . co m*/ } View selectedChild = mTabStrip.getChildAt(tabIndex); if (selectedChild != null) { int targetScrollX = selectedChild.getLeft() + positionOffset; if (tabIndex > 0 || positionOffset > 0) { // If we're not at the first child and are mid-scroll, make sure // we obey the offset targetScrollX -= mTitleOffset; } scrollTo(targetScrollX, 0); } }
From source file:com.av.benzandroid.views.SlidingTabLayout.java
private void scrollToTab(int tabIndex, int positionOffset) { final int tabStripChildCount = mTabStrip.getChildCount(); if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) { return;/* www .j ava 2 s .c o m*/ } View selectedChild = mTabStrip.getChildAt(tabIndex); if (selectedChild != null) { int targetScrollX = selectedChild.getLeft() + positionOffset; if (tabIndex > 0 || positionOffset > 0) { // If we're not at the first child and are mid-scroll, make sure we obey the offset targetScrollX -= mTitleOffset; } //Elv - Reinitialize color of tabs for (int i = 0; i < mTabStrip.getChildCount(); i++) { if (tabIndex == i) { //Set text colot of current selected tab ((TextView) selectedChild).setTextColor(SELECTED_TEXTVIEW_COLOR); } else { TextView tab = (TextView) mTabStrip.getChildAt(i); tab.setTextColor(DEFAULT_TEXTVIEW_COLOR); } } scrollTo(targetScrollX, 0); } }
From source file:com.al70b.core.extended_widgets.SlidingTabLayout.java
private void scrollToTab(int tabIndex, int positionOffset) { final int tabStripChildCount = mTabStrip.getChildCount(); if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) { return;//from w w w . j a va 2 s .com } View selectedChild = mTabStrip.getChildAt(tabIndex); if (selectedChild != null) { int targetScrollX = selectedChild.getLeft() + positionOffset; if (tabIndex > 0 || positionOffset > 0) { // If we're not at the first child and are mid-scroll, make sure we obey the offset targetScrollX -= mTitleOffset; } scrollTo(targetScrollX, 0); // Handle tabs coloring if (selectedChild instanceof TextView) { TextView prev = (TextView) mTabStrip.getChildAt(mTabStrip.getPreviousPosition()); if (!prev.equals(selectedChild)) prev.setTextColor(getResources().getColor(android.R.color.darker_gray)); ((TextView) selectedChild).setTextColor(getResources().getColor(R.color.white)); } else if (selectedChild instanceof LinearLayout) { return; } } }
From source file:com.base.app.widget.indicatorview.TabPageIndicator.java
@Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); if (isInEditMode() || count == 0) { return;//w w w. ja va2 s .co m } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = mTabLayout.getChildAt(currentPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); // if there is an offset, start interpolating left and right coordinates between current and next tab if (currentPositionOffset > 0f && currentPosition < count - 1) { View nextTab = mTabLayout.getChildAt(currentPosition + 1); final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); } canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, mTabLayout.getWidth(), height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < count - 1; i++) { View tab = mTabLayout.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:ameircom.keymedia.Activity.transition.FabTransform.java
private void captureValues(TransitionValues transitionValues) { final View view = transitionValues.view; if (view == null || view.getWidth() <= 0 || view.getHeight() <= 0) return;//from w w w . j a v a 2 s.c om transitionValues.values.put(PROP_BOUNDS, new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())); }
From source file:com.ben.gank.adapter.SortTypeAdapter.java
@Override public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) { // x, y --- relative from the itemView's top-left // return false if the item is a section header if (holder.getItemViewType() != ITEM_VIEW_TYPE_SECTION_ITEM) { return false; }/*from w ww . j a v a 2s. co m*/ final View containerView = holder.mContainer; final View dragHandleView = holder.mDragHandle; final int offsetX = containerView.getLeft() + (int) (ViewCompat.getTranslationX(containerView) + 0.5f); final int offsetY = containerView.getTop() + (int) (ViewCompat.getTranslationY(containerView) + 0.5f); return ViewUtils.hitTest(dragHandleView, x - offsetX, y - offsetY); }