List of usage examples for android.view View getRight
@ViewDebug.CapturedViewProperty public final int getRight()
From source file:base.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;// w ww . j a v a2 s. c o m } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); Pair<Float, Float> lines = getIndicatorCoordinates(); canvas.drawRect(lines.first + paddingLeft, height - indicatorHeight, lines.second + paddingRight, height, rectPaint); // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(paddingLeft, height - underlineHeight, tabsContainer.getWidth() + paddingRight, height, rectPaint); // draw divider if (dividerWidth != 0) { dividerPaint.setStrokeWidth(dividerWidth); dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } } }
From source file:com.gx.appstore.lib.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;/* www . ja va2s. c o m*/ } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.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 < tabCount - 1) { View nextTab = tabsContainer.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); } // // /** x1 = lineLeft+(lineRight-lineLeft)/2; y1 = height - indicatorHeight; x2 = x1 + triangleWidth/2; y2 = height; x3 = x1 - triangleWidth/2; y3 = height */ Path path = new Path(); float x1 = lineLeft + (lineRight - lineLeft) / 2; float y1 = height - indicatorHeight; int triangleWidth = 30; float x2 = x1 + triangleWidth / 2; float y2 = height; float x3 = x1 - triangleWidth / 2; float y3 = height; path.moveTo(x1, y1); path.lineTo(x2, y2); path.lineTo(x3, y3); path.lineTo(x1, y1); // canvas.drawPath(path, rectPaint); canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:com.library.core.view.HorizontalListView.java
private void fillSpecific(int position, int top) { View child = mAdapter.getView(position, null, null); if (child == null) return;/*from www .ja v a 2s .co m*/ addAndMeasureChild(child, -1); int edge = 0; edge = child.getRight(); fillListRight(edge, top); edge = child.getLeft(); fillListLeft(edge, top); }
From source file:com.benefit.buy.library.viewpagerindicator.PagerSlidingTabStrip.java
@SuppressLint("NewApi") @Override/* w w w . j a v a2s . co m*/ protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || (tabCount == 0)) { return; } final int height = getHeight(); // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.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 < (tabCount - 1))) { View nextTab = tabsContainer.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)); } if (currentTab.findViewById(R.id.img_click) != null) { int counts = tabsContainer.getChildCount(); View vNow = currentTab.findViewById(R.id.tab_name); ImageView imgNowOn = (ImageView) currentTab.findViewById(R.id.img_click); View tabViewNext; View vNext; ImageView imgNextOn; if ((currentPosition + 1) == counts) { tabViewNext = tabsContainer.getChildAt(0); vNext = tabViewNext.findViewById(R.id.tab_name); imgNextOn = (ImageView) tabViewNext.findViewById(R.id.img_click); } else { tabViewNext = tabsContainer.getChildAt(currentPosition + 1); vNext = tabViewNext.findViewById(R.id.tab_name); imgNextOn = (ImageView) tabViewNext.findViewById(R.id.img_click); } int colorTo = ToolColor.getChangeColor(80, 84, 98, 255, 0, 0, currentPositionOffset); int colorRe = ToolColor.getChangeColor(255, 0, 0, 80, 84, 98, currentPositionOffset); TextView tab = (TextView) vNext; TextView tab2 = (TextView) vNow; tab.setTextColor(colorTo); tab2.setTextColor(colorRe); if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { imgNextOn.setAlpha(currentPositionOffset); imgNowOn.setAlpha(1 - currentPositionOffset); } } else { } canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < (tabCount - 1); i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:com.liushengfan.test.customerviewgroup.view.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;/*from www. j a va 2s . c o m*/ } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.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 < tabCount - 1) { View nextTab = tabsContainer.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, tabsContainer.getWidth(), height, rectPaint); canvas.drawRect(0, 0, tabsContainer.getWidth(), underlineHeight, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:com.cmax.bodysheild.widget.PagerSlidingTabStripExtends.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;//from w w w.j a va 2 s . co m } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.getChildAt(currentPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); // if there is an offset, startSingleFile interpolating left and right coordinates between current and next tab if (currentPositionOffset > 0f && currentPosition < tabCount - 1) { View nextTab = tabsContainer.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); } // indicator canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); /* x = (lineRight-lineLeft)/2+lineLeft y = height - indicatorHeight */ /* int triangleWidth = 18; float x1 = (lineRight - lineLeft) / 2 + lineLeft; float y1 = height - indicatorHeight; float x2 = x1 - triangleWidth / 2; float y2 = height; float x3 = x1 + triangleWidth / 2; float y3 = height; Path path = new Path(); path.moveTo(x1, y1); path.lineTo(x2, y2); path.lineTo(x3, y3); path.lineTo(x1, y1); canvas.drawPath(path, rectPaint);*/ // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:com.hua.weget.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); LogUtils2.i("onDraw------------------------"); if (isInEditMode() || tabCount == 0) { return;/*from www . ja v a 2 s. c o m*/ } final int height = getHeight(); LogUtils2.w("getHeight();==" + getHeight()); // draw underline Tab viewpager rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.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 < tabCount - 1) { View nextTab = tabsContainer.getChildAt(currentPosition + 1); final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); LogUtils2.d("currentPositionOffset==" + currentPositionOffset); LogUtils2.d("nextTabLeft==" + nextTabLeft); LogUtils2.d("lineLeft==" + lineLeft); lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); // lineLeft = (currentPositionOffset * nextTabLeft) + (1f - currentPositionOffset) * lineLeft; } canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:cn.edu.qzu.face.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;// w ww . j a v a 2 s . c om } final int height = getHeight(); // draw indicator line rectPaint.setColor(indicatorColor); for (int i = 0; i < tabsContainer.getChildCount(); ++i) { View tab = tabsContainer.getChildAt(i); tab.setSelected(i == selectedPosition); } // default: line below current tab View currentTab = tabsContainer.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 < tabCount - 1) { View nextTab = tabsContainer.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); //Indicator /*View currentTab = tabsContainer.getChildAt(currentPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); if (currentTab instanceof TextView) { TextView textView = (TextView) currentTab; bound.setEmpty(); Paint textPaint = textView.getPaint(); textPaint.getTextBounds(textView.getText().toString(), 0, textView.getText().length(), bound); int padding = (textView.getWidth() - bound.width()) / 2; lineLeft = lineLeft + padding; lineRight = lineRight - padding; } if (currentPositionOffset > 0f && currentPosition < tabCount - 1) { View nextTab = tabsContainer.getChildAt(currentPosition + 1); float nextTabLeft = nextTab.getLeft(); float nextTabRight = nextTab.getRight(); if (nextTab instanceof TextView) { TextView textView = (TextView) nextTab; Rect bound = new Rect(); Paint textPaint = textView.getPaint(); textPaint.getTextBounds(textView.getText().toString(), 0, textView.getText().length(), bound); int padding = (textView.getWidth() - bound.width()) / 2; nextTabLeft = nextTabLeft + padding; nextTabRight = nextTabRight - padding; } 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, tabsContainer.getWidth(), height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:com.lizhi.library.widget.WechatTab.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;//from w ww .ja va 2 s . c o m } final int height = getHeight(); // draw underline rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw indicator line rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.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 < tabCount - 1) { View nextTab = tabsContainer.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); } // TextView tv = ((TextView) currentTab); // String s = tv.getText().toString(); // float widths[] = new float[s.length()]; // tv.getPaint().getTextWidths(s, widths); // float StringWidth = 0; // for (float item : widths) { // StringWidth += item; // } // int padding = (int) ((tv.getWidth() - StringWidth) / 2 - mMyUnderlinePadding); // if (padding < 0) { // padding = 0; // } if (!underLine) { canvas.drawRect(lineLeft, 0, lineRight, height, rectPaint); } else { canvas.drawRect(lineLeft + mMyUnderlinePadding, height - indicatorHeight, lineRight - mMyUnderlinePadding, height, rectPaint); } // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:com.little.pager.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;//from w w w. ja va2 s . c o m } final int height = getHeight(); // rectPaint.setColor(underlineColor); canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // rectPaint.setColor(indicatorColor); // default: line below current tab View currentTab = tabsContainer.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 < tabCount - 1) { View nextTab = tabsContainer.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 divider // if (hasDivier) { dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } } }