private void updateTitleBottomPadding() { if (isIconsOnlyMode()) { return; } int tabCount = getTabCount(); if (tabContainer == null || tabCount == 0 || !isShiftingMode()) { return; } for (int i = 0; i < tabCount; i++) { BottomBarTab tab = getTabAtPosition(i); TextView title = tab.getTitleView(); if (title == null) { continue; } int baseline = title.getBaseline(); int height = title.getHeight(); int paddingInsideTitle = height - baseline; int missingPadding = tenDp - paddingInsideTitle; if (missingPadding > 0) { title.setPadding(title.getPaddingLeft(), title.getPaddingTop(), title.getPaddingRight(), missingPadding + title.getPaddingBottom()); } } }
@Override public int getSuperPaddingBottom() { return super.getPaddingBottom(); } }
@Override public int getPaddingBottom() { if (super.getPaddingBottom() == 0) { return 0; } int textLength = this.getText().length(); if (textLength == 0) { return 0; } if (textLength == 1) { return super.getPaddingBottom() - extraPaddingVertical; } if (textLength > 1) { return super.getPaddingBottom() - minPaddingVertical; } return super.getPaddingBottom(); }
public void setAgencyNamePaddingRight(int paddingRight) { tvBestAgency.setPadding(tvBestAgency.getPaddingLeft(), tvBestAgency.getPaddingTop(), paddingRight, tvBestAgency.getPaddingBottom()); } }
private void setContent(String message, Integer paddingLeft) { TextView txtContent = (TextView) transitionsContainer.findViewById(R.id.txt_content); if( paddingLeft != null ) { int left = txtContent.getPaddingLeft(), top = txtContent.getPaddingTop(), right = txtContent.getPaddingRight(), bottom = txtContent.getPaddingBottom(); txtContent.setPadding( left +paddingLeft, top, right, bottom ); } txtContent.setText(message); }
/** * Set the top padding on the header view dynamically, based on whether the header is in * the first row or not. */ public static void setHeaderViewBottomPadding(Context context, TextView textView, boolean isFirstRow) { final int topPadding; if (isFirstRow) { topPadding = (int) context.getResources().getDimension( R.dimen.frequently_contacted_title_top_margin_when_first_row); } else { topPadding = (int) context.getResources().getDimension( R.dimen.frequently_contacted_title_top_margin); } textView.setPaddingRelative(textView.getPaddingStart(), topPadding, textView.getPaddingEnd(), textView.getPaddingBottom()); }
@NonNull private static Intent getDetailActivityStartIntent(Activity host, ArrayList<Photo> photos, int position, PhotoItemBinding binding) { final Intent intent = new Intent(host, DetailActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.putParcelableArrayListExtra(IntentUtil.PHOTO, photos); intent.putExtra(IntentUtil.SELECTED_ITEM_POSITION, position); intent.putExtra(IntentUtil.FONT_SIZE, binding.author.getTextSize()); intent.putExtra(IntentUtil.PADDING, new Rect(binding.author.getPaddingLeft(), binding.author.getPaddingTop(), binding.author.getPaddingRight(), binding.author.getPaddingBottom())); intent.putExtra(IntentUtil.TEXT_COLOR, binding.author.getCurrentTextColor()); return intent; }
@Override public void onGlobalLayout() { mView.getViewTreeObserver().removeGlobalOnLayoutListener(this); mPaddingLeft = mView.getPaddingLeft(); mPaddingRight = mView.getPaddingRight(); mPaddingTop = mView.getPaddingTop(); mPaddingBottom = mView.getPaddingBottom(); setIcon(); } });
private static void applyFixForPre21ver(TextView tv) { int paddingBottom = tv.getPaddingBottom(); paddingBottom = paddingBottom - (int) tv.getLineSpacingExtra(); tv.setPadding(tv.getPaddingLeft(), tv.getPaddingTop(), tv.getPaddingRight(), paddingBottom); } }
public static void setPaddingStart(TextView target, int paddingStart) { ViewCompat.setPaddingRelative(target, paddingStart, target.getPaddingTop(), ViewCompat.getPaddingEnd(target), target.getPaddingBottom()); }
@Override public void setValue(TextView view, int paddingStart) { ViewCompat.setPaddingRelative(view, paddingStart, view.getPaddingTop(), ViewCompat.getPaddingEnd(view), view.getPaddingBottom()); } };
@Override public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { TextView author = getAuthor(); targetTextSize = author.getTextSize(); targetTextColors = author.getTextColors(); targetPadding = new Rect(author.getPaddingLeft(), author.getPaddingTop(), author.getPaddingRight(), author.getPaddingBottom()); if (IntentUtil.hasAll(intent, IntentUtil.TEXT_COLOR, IntentUtil.FONT_SIZE, IntentUtil.PADDING)) { author.setTextColor(intent.getIntExtra(IntentUtil.TEXT_COLOR, Color.BLACK)); float textSize = intent.getFloatExtra(IntentUtil.FONT_SIZE, targetTextSize); author.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); Rect padding = intent.getParcelableExtra(IntentUtil.PADDING); author.setPadding(padding.left, padding.top, padding.right, padding.bottom); } }
private boolean updateViewsWithinLayout(final int orientation, final int messagePadTop, final int messagePadBottom) { boolean changed = false; if (orientation != getOrientation()) { setOrientation(orientation); changed = true; } if (mMessageView.getPaddingTop() != messagePadTop || mMessageView.getPaddingBottom() != messagePadBottom) { updateTopBottomPadding(mMessageView, messagePadTop, messagePadBottom); changed = true; } return changed; }
private static void setLeading(TextView view, int step, int leading) { // This is to make the behavior more deterministic: remove extra top/bottom padding view.setIncludeFontPadding(false); // Get font metrics and calculate required inter-line extra Paint.FontMetricsInt metrics = view.getPaint().getFontMetricsInt(); final int extra = leading - metrics.descent + metrics.ascent; view.setLineSpacing(extra, 1); // Determine minimum required top extra so that the view lands on the grid final int alignTopExtra = (step + metrics.ascent % step) % step; // Determine minimum required bottom extra so that view bounds are aligned with the grid final int alignBottomExtra = (step - metrics.descent % step) % step; view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + alignTopExtra, view.getPaddingRight(), view.getPaddingBottom() + alignBottomExtra); }
private boolean updateViewsWithinLayout(final int orientation, final int messagePadTop, final int messagePadBottom) { boolean changed = false; if (orientation != getOrientation()) { setOrientation(orientation); changed = true; } if (mMessageView.getPaddingTop() != messagePadTop || mMessageView.getPaddingBottom() != messagePadBottom) { updateTopBottomPadding(mMessageView, messagePadTop, messagePadBottom); changed = true; } return changed; }
private boolean updateViewsWithinLayout(final int orientation, final int messagePadTop, final int messagePadBottom) { boolean changed = false; if (orientation != getOrientation()) { setOrientation(orientation); changed = true; } if (mMessageView.getPaddingTop() != messagePadTop || mMessageView.getPaddingBottom() != messagePadBottom) { updateTopBottomPadding(mMessageView, messagePadTop, messagePadBottom); changed = true; } return changed; }
private static Bitmap captureTextBitmap(TextView textView) { Drawable background = textView.getBackground(); textView.setBackground(null); int width = textView.getWidth() - textView.getPaddingLeft() - textView.getPaddingRight(); int height = textView.getHeight() - textView.getPaddingTop() - textView.getPaddingBottom(); if (width == 0 || height == 0) { return null; } Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.translate(-textView.getPaddingLeft(), -textView.getPaddingTop()); textView.draw(canvas); textView.setBackground(background); return bitmap; }
private static Bitmap captureTextBitmap(TextView textView) { Drawable background = textView.getBackground(); textView.setBackground(null); int width = textView.getWidth() - textView.getPaddingLeft() - textView.getPaddingRight(); int height = textView.getHeight() - textView.getPaddingTop() - textView.getPaddingBottom(); if (width == 0 || height == 0) { return null; } Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.translate(-textView.getPaddingLeft(), -textView.getPaddingTop()); textView.draw(canvas); textView.setBackground(background); return bitmap; }
public TextResizeData(TextView textView) { this.paddingLeft = textView.getPaddingLeft(); this.paddingTop = textView.getPaddingTop(); this.paddingRight = textView.getPaddingRight(); this.paddingBottom = textView.getPaddingBottom(); this.width = textView.getWidth(); this.height = textView.getHeight(); this.gravity = textView.getGravity(); this.textColor = textView.getCurrentTextColor(); } }
public TextResizeData(TextView textView) { this.paddingLeft = textView.getPaddingLeft(); this.paddingTop = textView.getPaddingTop(); this.paddingRight = textView.getPaddingRight(); this.paddingBottom = textView.getPaddingBottom(); this.width = textView.getWidth(); this.height = textView.getHeight(); this.gravity = textView.getGravity(); this.textColor = textView.getCurrentTextColor(); } }