List of usage examples for android.widget TextView getLeft
@ViewDebug.CapturedViewProperty public final int getLeft()
From source file:Main.java
public static boolean drawDrawables(Canvas canvas, @Nonnull TextView textView) { final int compoundPaddingLeft = textView.getCompoundPaddingLeft(); final int compoundPaddingTop = textView.getCompoundPaddingTop(); final int compoundPaddingRight = textView.getCompoundPaddingRight(); final int compoundPaddingBottom = textView.getCompoundPaddingBottom(); final int scrollX = textView.getScrollX(); final int scrollY = textView.getScrollY(); final int right = textView.getRight(); final int left = textView.getLeft(); final int bottom = textView.getBottom(); final int top = textView.getTop(); final Drawable[] drawables = textView.getCompoundDrawables(); if (drawables != null) { int vspace = bottom - top - compoundPaddingBottom - compoundPaddingTop; int hspace = right - left - compoundPaddingRight - compoundPaddingLeft; Drawable topDr = drawables[1];//ww w .j a va 2s .c o m // IMPORTANT: The coordinates computed are also used in invalidateDrawable() // Make sure to update invalidateDrawable() when changing this code. if (topDr != null) { canvas.save(); canvas.translate(scrollX + compoundPaddingLeft + (hspace - topDr.getBounds().width()) / 2, scrollY + textView.getPaddingTop() + vspace / 2); topDr.draw(canvas); canvas.restore(); return true; } } return false; }
From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.widget.ScrollableTabs.java
public void focusTab(int index) { final int tabCount = mHost.getChildCount(); if (index < 0 || index > tabCount - 1) { return;//from w w w . ja va2s.c o m } if (mCurrentTab != index) { final TextView tvOld = (TextView) mHost.getChildAt(mCurrentTab); if (tvOld != null) { tvOld.setSelected(false); } mCurrentTab = index; final TextView tvNew = (TextView) mHost.getChildAt(index); if (tvNew != null) { int right = tvNew.getRight(); int left = tvNew.getLeft() + right; int width = getWidth(); int i = (left - width) / 2; tvNew.setSelected(true); smoothScrollTo(i, 0); } } }
From source file:com.viewpagerindicator.TabMovablePageIndicator.java
private void moveIndicator(TextView tabView) { int left = tabView.getLeft(); int width = tabView.getWidth(); int textWidth = getTextWidth(tabView.getText().toString(), tabView.getTextSize(), tabView.getTypeface()); int x = left + (width - textWidth) / 2; LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(textWidth, mIndicator.getLayoutParams().height); lp.leftMargin = x;// w w w. jav a 2 s .co m mIndicator.setLayoutParams(lp); }
From source file:com.timothy.android.api.fragment.LeftFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.left_list, null); title = (TextView) view.findViewById(R.id.indexTV); int branchIndex = SPUtil.getIntegerFromSP(SPUtil.CURRENT_BRANCH_INDEX, sp); if (branchIndex != -1 && branchNames != null) { title.setText(branchNames[branchIndex - 1]); }/*from w w w .j a v a2s . com*/ title.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { TextView tv = (TextView) arg0; if (view.getVisibility() == View.VISIBLE && tv.getVisibility() == View.VISIBLE) { if (branchNames != null && branchNames.length > 0) { tv.getTop(); int y = tv.getBottom() * 3 / 2; int x = tv.getLeft(); // int x = activity.getWindowManager().getDefaultDisplay().getWidth() / 4; showPopupWindow(x, y); } } } }); return view; }
From source file:za.jamie.soundstage.widgets.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;//from ww w. jav a 2s . c om } final int height = getHeight(); // default: line below current tab TextView currentTab = (TextView) 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) { TextView nextTab = (TextView) 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); int currentTabColor = (Integer) tabTextColorEvaluator.evaluate(currentPositionOffset, tabSelectedTextColor, tabTextColor); currentTab.setTextColor(currentTabColor); int nextTabColor = (Integer) tabTextColorEvaluator.evaluate(currentPositionOffset, tabTextColor, tabSelectedTextColor); nextTab.setTextColor(nextTabColor); } canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, indicatorPaint); // draw underline canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, underlinePaint); // draw divider for (int i = 0; i < tabCount - 1; i++) { final int tabRight = tabsContainer.getChildAt(i).getRight(); canvas.drawLine(tabRight, dividerPadding, tabRight, height - dividerPadding, dividerPaint); } }
From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.TabPageIndicator.java
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); TextView tv = getTabView(mSelectedPosition); if (tv != null) updateIndicator(tv.getLeft(), tv.getMeasuredWidth()); }
From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.TabPageIndicator.java
@Override public void onPageScrollStateChanged(int state) { if (state == ViewPager.SCROLL_STATE_IDLE) { mScrolling = false;//from w ww . j av a 2s .c om TextView tv = getTabView(mSelectedPosition); if (tv != null) { updateIndicator(tv.getLeft(), tv.getMeasuredWidth()); } } else mScrolling = true; if (mListener != null) mListener.onPageScrollStateChanged(state); }
From source file:dcheungaa.procal.MainActivity.java
@Override public void onWindowFocusChanged(boolean hasFocus) { TextView cursor = (TextView) MainActivity.views.get("cursor"); TextView matrixDisplay = (TextView) MainActivity.views.get("matrixDisplay"); super.onWindowFocusChanged(hasFocus); if (call_load) { call_load = false;//from ww w. j a v a2s . c o m fontWidth = cursor.getWidth(); fontHeight = cursor.getHeight(); cursor.setText(Character.toString((char) 0x258E)); //cursor.setTop(matrixDisplay.getTop()); cursor.setPadding(matrixDisplay.getPaddingLeft(), cursor.getPaddingTop(), cursor.getPaddingRight(), cursor.getPaddingBottom()); cursor.setLeft(matrixDisplay.getLeft()); //CursorHandler.hideCursor(); RelativeLayout cm = (RelativeLayout) findViewById(R.id.content_main); LinearLayout rows = (LinearLayout) findViewById(R.id.llKeyPad); keyPad.KeyPad_resize(cm, rows); int fnBtnHeight = keyPad.btn_rows.get(0).get(0).get_mheight(); System.out.print(Integer.toString(fnBtnHeight)); varPad.resize(fnBtnHeight, fnBtnHeight * 3, svVar); cmdPad.resize(fnBtnHeight, fnBtnHeight * 3, svCmd); constPad.resize(fnBtnHeight, fnBtnHeight * 3, svConst); } }
From source file:net.arvin.afbaselibrary.widgets.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || tabCount == 0) { return;/* www . ja v a 2s . c o m*/ } final int height = getHeight(); // draw underline if (clear) { rectPaint.setColor(Color.WHITE); } else { rectPaint.setColor(underlineColor); } canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw indicator line if (clear) { rectPaint.setColor(Color.WHITE); } else { rectPaint.setColor(indicatorColor); } // default: line below current tab TextView currentTab = (TextView) tabsContainer.getChildAt(currentPosition); int textLength = currentTab.getText().length() * ScreenUtil.sp2px(tabTextSize); float lineLeft = (currentTab.getRight() - currentTab.getLeft() - textLength) / 2 + ScreenUtil.dp2px(4) + currentTab.getLeft(); float lineRight = lineLeft + textLength - ScreenUtil.dp2px(4) * 2; if (tabAddWay == TabAddWay.ITEM_MATCH) { lineLeft = currentTab.getLeft(); 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); float nextTabLeft = (nextTab.getRight() - nextTab.getLeft() - textLength) / 2 + ScreenUtil.dp2px(4) + nextTab.getLeft(); float nextTabRight = nextTabLeft + textLength - ScreenUtil.dp2px(4) * 2; if (tabAddWay == TabAddWay.ITEM_MATCH) { nextTabLeft = nextTab.getLeft(); 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 (clear) { dividerPaint.setColor(Color.WHITE); } else { dividerPaint.setColor(dividerColor); } if (isDrawDivider) { 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.csdn.pagerslidingtabstrip.view.PagerSlidingTabStrip.java
private void choose(int fromPosition, int toPosition) { TextView lastTab = (TextView) tabsContainer.getChildAt(fromPosition); lastTab.setTextColor(tabTextColor);//from w ww .j av a 2 s .c om TextView currentTab = (TextView) tabsContainer.getChildAt(toPosition); currentTab.setTextColor(selectedTabTextColor); currentPosition = toPosition; float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); detalLeft = lineLeft - lastTab.getLeft(); detalRight = lineRight - lastTab.getRight(); final float minDetal = (lineRight - lineLeft) / 2; this.post(new Runnable() { @Override public void run() { if (Math.abs(detalLeft) > minDetal || Math.abs(detalRight) > minDetal) { if (Math.abs(detalLeft) > minDetal) { detalLeft = detalLeft / minDetal; } if (Math.abs(detalRight) > minDetal) { detalRight = detalRight / minDetal; } invalidate(); PagerSlidingTabStrip.this.post(this); } else { invalidate(); } } }); }