android.widget.TextView.getPaddingTop()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中android.widget.TextView.getPaddingTop()方法的一些代码示例,展示了TextView.getPaddingTop()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getPaddingTop()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getPaddingTop

TextView.getPaddingTop介绍

暂无

代码示例

代码示例来源:origin: roughike/BottomBar

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());
    }
  }
}

代码示例来源:origin: cpiz/BubbleView

@Override
public int getSuperPaddingTop() {
  return super.getPaddingTop();
}

代码示例来源:origin: ShonLin/QuickDevFramework

@Override
public int getPaddingTop() {
  if (super.getPaddingTop() == 0) {
    return 0;
  }
  int textLength = this.getText().length();
  if (textLength == 0) {
    return 0;
  }
  if (textLength == 1) {
    return super.getPaddingTop() - extraPaddingVertical;
  }
  if (textLength > 1) {
    return super.getPaddingTop() - minPaddingVertical;
  }
  return super.getPaddingTop();
}

代码示例来源:origin: KosyanMedia/Aviasales-Android-SDK

public void setAgencyNamePaddingRight(int paddingRight) {
    tvBestAgency.setPadding(tvBestAgency.getPaddingLeft(),
        tvBestAgency.getPaddingTop(),
        paddingRight,
        tvBestAgency.getPaddingBottom());
  }
}

代码示例来源:origin: stackoverflow.com

protected void showDialog(Bundle state) {
  super.showDialog(state);
  int id = getContext().getResources().getIdentifier("message", "id", "android");
  TextView message = (TextView) getDialog().findViewById(id);
  message.setPadding(message.getPaddingLeft(), message.getPaddingTop(), message.getPaddingRight(), 0);
}

代码示例来源:origin: MCMrARM/revolution-irc

public HeaderHolder(View view) {
  super(view);
  mText = (TextView) view.findViewById(R.id.title);
  mText.setPadding(mText.getPaddingLeft(), mText.getPaddingTop(), mText.getPaddingRight(), mText.getResources().getDimensionPixelSize(R.dimen.notification_rule_list_header_padding));
}

代码示例来源:origin: BROUDING/SimpleDialog

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);
}

代码示例来源:origin: googlesamples/android-unsplash

@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;
}

代码示例来源:origin: RuffianZhong/RWidgetHelper

@Override
  public void onGlobalLayout() {
    mView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
    mPaddingLeft = mView.getPaddingLeft();
    mPaddingRight = mView.getPaddingRight();
    mPaddingTop = mView.getPaddingTop();
    mPaddingBottom = mView.getPaddingBottom();
    setIcon();
  }
});

代码示例来源:origin: GrossumUA/TAS_Android_Boilerplate

private static void applyFixForPre21ver(TextView tv) {
    int paddingBottom = tv.getPaddingBottom();
    paddingBottom = paddingBottom - (int) tv.getLineSpacingExtra();
    tv.setPadding(tv.getPaddingLeft(), tv.getPaddingTop(), tv.getPaddingRight(), paddingBottom);
  }
}

代码示例来源:origin: googlecodelabs/android-topeka

@Override
  public void setValue(TextView view, int paddingStart) {
    ViewCompat.setPaddingRelative(view, paddingStart, view.getPaddingTop(),
        ViewCompat.getPaddingEnd(view), view.getPaddingBottom());
  }
};

代码示例来源:origin: googlecodelabs/android-topeka

public static void setPaddingStart(TextView target, int paddingStart) {
  ViewCompat.setPaddingRelative(target, paddingStart, target.getPaddingTop(),
      ViewCompat.getPaddingEnd(target), target.getPaddingBottom());
}

代码示例来源:origin: DroidsOnRoids/Workcation

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;
}

代码示例来源:origin: googlesamples/android-unsplash

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;
}

代码示例来源:origin: stackoverflow.com

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);
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

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;
}

代码示例来源:origin: HuanHaiLiuXin/SweetTips

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;
}

代码示例来源:origin: the-pig-of-jungle/smart-show

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;
}

代码示例来源:origin: googlesamples/android-unsplash

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();
  }
}

代码示例来源:origin: DroidsOnRoids/Workcation

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();
  }
}

相关文章

微信公众号

最新文章

更多

TextView类方法