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

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

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

TextView.setPaddingRelative介绍

暂无

代码示例

代码示例来源:origin: Sea-n/Android-TG-Bot

private void newHeader(final LinearLayout linearLayout, final String title) {
  TextView titleView = new TextView(context);
  titleView.setText(title);
  titleView.setTextSize(15);
  titleView.setTextColor(Color.rgb(0x10, 0x30, 0xc0));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
    titleView.setPaddingRelative(40, 60, 40, 10);
  linearLayout.addView(titleView);
}

代码示例来源:origin: AlexMofer/ProjectX

private void setAll(FloatingMenuItem item) {
  mIcon.setVisibility(VISIBLE);
  mIcon.setImageDrawable(item.getIcon());
  mText.setVisibility(VISIBLE);
  if (Build.VERSION.SDK_INT >= 16)
    mText.setPaddingRelative(mPaddingText, 0, 0, 0);
  else
    mText.setPadding(mPaddingText, 0, 0, 0);
  mText.setText(item.getTitle());
}

代码示例来源:origin: THEONE10211024/ApiDemos

public TextView getGenericView() {
  // Layout parameters for the ExpandableListView
  AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
      ViewGroup.LayoutParams.MATCH_PARENT, 64);
  TextView textView = new TextView(ExpandableList1.this);
  textView.setLayoutParams(lp);
  // Center the text vertically
  textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
  // Set the text starting position
  textView.setPaddingRelative(36, 0, 0, 0);
  // Set the text alignment
  textView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
  return textView;
}

代码示例来源:origin: qiubiteme/android_api_demos

public TextView getGenericView() {
  // Layout parameters for the ExpandableListView
  AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
      ViewGroup.LayoutParams.MATCH_PARENT, 64);
  TextView textView = new TextView(ExpandableList1.this);
  textView.setLayoutParams(lp);
  // Center the text vertically
  textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
  // Set the text starting position
  textView.setPaddingRelative(36, 0, 0, 0);
  // Set the text alignment
  textView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
  return textView;
}

代码示例来源:origin: Sea-n/Android-TG-Bot

titleView.setTextColor(Color.BLACK);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
  titleView.setPaddingRelative(40, 20, 40, 3);
linearLayout.addView(titleView);
    titleView.setPaddingRelative(40, 30, 40, 3);
    descView.setPaddingRelative(40, 3, 40, 20);
    titleView.setPaddingRelative(40, 40, 40, 40);

代码示例来源:origin: geniusgithub/AndroidDialer

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

代码示例来源:origin: wasdennnoch/AndroidN-ify

ProgressBar progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
activityText.setPaddingRelative(activityTextPadding, 0, activityTextPadding, 0);

代码示例来源:origin: Sea-n/Android-TG-Bot

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
  final FavStructure fav = iList.get(position);
  GridLayout gridLayout = (GridLayout) holder.itemView;
  gridLayout.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      Intent mIntent = new Intent(view.getContext(), AddFavoriteActivity.class);
      mIntent.putExtra("id", fav._id);
      view.getContext().startActivity(mIntent);
    }
  });
  final int valWidth = parentWidth * 2 / 3;
  final int nameWidth = parentWidth - valWidth;
  TextView valView = new TextView(gridLayout.getContext());
  valView.setText(fav.value);
  valView.setWidth(valWidth);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
    valView.setPaddingRelative(0, 0, 20, 0);
  gridLayout.addView(valView);
  TextView nameView = new TextView(gridLayout.getContext());
  nameView.setText(fav.name);
  nameView.setWidth(nameWidth);
  gridLayout.addView(nameView);
}

代码示例来源:origin: listenzz/AndroidNavigation

button.setWidth(size);
button.setHeight(size);
button.setPaddingRelative(padding, 0, padding, 0);
TypedValue typedValue = new TypedValue();
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP || Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) {
button.setPaddingRelative(padding, 0, padding, 0);
button.setText(buttonItem.title);
button.setTextColor(colorStateList);

相关文章

TextView类方法