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

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

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

TextView.getPaddingLeft介绍

暂无

代码示例

代码示例来源:origin: grantland/android-autofittextview

int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
if (targetWidth <= 0) {
  return;

代码示例来源: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: stackoverflow.com

int width = tv.getWidth() - tv.getPaddingLeft() - tv.getPaddingRight();
if(width == 0)

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

@Override
public int getSuperPaddingLeft() {
  return super.getPaddingLeft();
}

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

private void setBackground(TextView textView, DividerDrawable background) {
  Drawable drawableLeft = textView.getCompoundDrawables()[0];
  int paddingLeft = drawableLeft != null ?
      textView.getPaddingLeft() + drawableLeft.getIntrinsicWidth() + textView.getCompoundDrawablePadding() :
      textView.getPaddingLeft();
  background.setPaddingLeft(paddingLeft);
  textView.setBackground(background);
}

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

public static final int FinallwidthDp  = 320 ;
  public static final int widthJustify  = 223 ;
  DisplayMetrics metrics = new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(metrics);
  int widthPixels = metrics.widthPixels;
  float scaleFactor = metrics.density;
  float widthDp = widthPixels / scaleFactor;
  TextView tv = (TextView) findViewById(R.id.textView1);
  ViewGroup.MarginLayoutParams lp1 = (ViewGroup.MarginLayoutParams) tv.getLayoutParams();
  tv.setText(text);
  TextJustify.run(tv,widthDp / FinallwidthDp * widthJustify , tv.getPaddingLeft(),tv.getPaddingRight() , lp1.leftMargin, lp1.rightMargin);

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

public static final int FinallwidthDp  = 320 ;
public static final int widthJustify  = 223 ;
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int widthPixels = metrics.widthPixels;
float scaleFactor = metrics.density;
float widthDp = widthPixels / scaleFactor;
TextView tv = (TextView) findViewById(R.id.textView1);
ViewGroup.MarginLayoutParams lp1 = (ViewGroup.MarginLayoutParams) tv.getLayoutParams();
tv.setText(text);
TextJustify.run(tv,widthDp / FinallwidthDp * widthJustify , tv.getPaddingLeft(),tv.getPaddingRight() , lp1.leftMargin, lp1.rightMargin);

代码示例来源:origin: wangchenyan/html-text

private int getTextWidth() {
    DisplayMetrics dm = getResources().getDisplayMetrics();
    return dm.widthPixels - textView.getPaddingLeft() - textView.getPaddingRight();
  }
}

代码示例来源: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: hejunlin2013/EpisodeListView

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  View view = LayoutInflater.from(parent.getContext())
      .inflate(R.layout.parent_item, parent, false);
  MyViewHolder holder = new MyViewHolder(view);
  parentWidth = parent.getMeasuredWidth();
  itemWidth = (parentWidth -
      (holder.textView.getPaddingLeft() + holder.textView.getPaddingRight()) * (GROUPS_COLUMN_COUNT))
      / GROUPS_COLUMN_COUNT + 1;
  return holder;
}

代码示例来源: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: hejunlin2013/EpisodeListView

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  View view = LayoutInflater.from(parent.getContext())
      .inflate(R.layout.child_item, parent, false);
  MyViewHolder holder = new MyViewHolder(view);
  parentWidth = parent.getMeasuredWidth();
  itemWidth = (parentWidth -
      (holder.textView.getPaddingLeft() + holder.textView.getPaddingRight()) * (EPISODES_COLUMN_COUNT))
      / EPISODES_COLUMN_COUNT + 1;
  return holder;
}

代码示例来源: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: 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: 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();
  }
}

代码示例来源: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();
  }
}

相关文章

TextView类方法