List of usage examples for android.widget TextView getTotalPaddingRight
public int getTotalPaddingRight()
From source file:com.frostwire.android.gui.views.KeywordTagView.java
private void updateComponents() { SpannableStringBuilder sb = new SpannableStringBuilder(); sb = append(sb, keywordFilter.getKeyword(), keywordSpan, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); if (count != -1) { sb = append(sb, " (" + String.valueOf(count) + ")", countSpan, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }/*from www. j av a2 s . c o m*/ setText(sb, TextView.BufferType.NORMAL); if (dismissible) { setBackgroundResource(R.drawable.keyword_tag_background_active); int drawableResId = keywordFilter.isInclusive() ? R.drawable.keyword_tag_filter_add : R.drawable.keyword_tag_filter_minus; setCompoundDrawablesWithIntrinsicBounds(drawableResId, 0, R.drawable.keyword_tag_close_clear_cancel_full, 0); setTextColor(ContextCompat.getColor(getContext(), R.color.app_text_white)); } else { setBackgroundResource(R.drawable.keyword_tag_background); setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); setTextColor(ContextCompat.getColor(getContext(), R.color.app_text_primary)); } setOnClickListener(v -> onTouched()); if (dismissible) { setOnTouchListener((v, event) -> { if (event.getAction() != MotionEvent.ACTION_UP) { return false; } TextView tv = (TextView) v; if (event.getX() >= tv.getWidth() - tv.getTotalPaddingRight()) { onDismissed(); return true; } return false; }); } }
From source file:com.resonos.apps.library.tabviewpager.TabPageIndicator.java
/** * Does a bit of calculations to better measure the size of tabs. * This is to fix a bug where text would occasionally get cut off. */// ww w . java 2 s. co m private void doPreMeasure() { TabView tabView = (TabView) mInflater.inflate(R.layout.vpi__tab, null); TextView textView = (TextView) tabView.findViewById(android.R.id.text1); ImageView imageView = (ImageView) tabView.findViewById(R.id.img); mTextPaint = textView.getPaint(); mTextPadding = textView.getTotalPaddingLeft() + textView.getTotalPaddingRight() + tabView.getPaddingLeft() + tabView.getPaddingRight(); int mImagePadding = imageView.getPaddingLeft() + imageView.getPaddingRight(); int t = 0; int count = getTitleProvider().getCount(); mAllMinWidths = new int[count]; String text; Drawable d; for (int i = 0; i < count; i++) { d = getTitleProvider().getIcon(i); text = getTitleProvider().getTitle(i); if (d != null) { mAllMinWidths[i] = d.getIntrinsicWidth() + mImagePadding; } else { StaticLayout layout = new StaticLayout(text, mTextPaint, MAX_TAB_WIDTH, Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); int w = (int) (layout.getLineWidth(0) + 1); mAllMinWidths[i] = mTextPadding + w; } if (getTitleProvider().isVisible(i)) t += mAllMinWidths[i]; } mTotalMinWidth = t; }
From source file:com.juick.android.MessageMenu.java
private float convertToLocalHorizontalCoordinate(TextView textView2, float x) { x -= textView2.getTotalPaddingLeft(); // Clamp the position to inside of the view. x = Math.max(0.0f, x);//from ww w .j ava2 s.c o m x = Math.min(textView2.getWidth() - textView2.getTotalPaddingRight() - 1, x); x += textView2.getScrollX(); return x; }