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

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

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

TextView.setTextColor介绍

暂无

代码示例

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

Snackbar snack = Snackbar.make(view, R.string.message, Snackbar.LENGTH_LONG);
View view = snack.getView();
TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
tv.setTextColor(Color.WHITE);
snack.show();

代码示例来源:origin: scwang90/SmartRefreshLayout

protected TextView createMaskView(Context context, String text, int textSize, int gravity) {
  final TextView maskView = new TextView(context);
  maskView.setTextColor(Color.BLACK);
  maskView.setGravity(gravity | Gravity.CENTER_HORIZONTAL);
  maskView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
  maskView.setText(text);
  //noinspection UnnecessaryLocalVariable
  final View view = maskView;
  view.setBackgroundColor(Color.WHITE);
  return maskView;
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Override
public void onTransitionResume(@NonNull Transition transition) {
  if (mChangeBehavior != CHANGE_BEHAVIOR_IN) {
    view.setText(startText);
    if (view instanceof EditText) {
      setSelection(((EditText) view), startSelectionStart, startSelectionEnd);
    }
  }
  if (mChangeBehavior > CHANGE_BEHAVIOR_KEEP) {
    view.setTextColor(mPausedColor);
  }
}

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

// Create the Snackbar
Snackbar snackbar = Snackbar.make(containerLayout, "", Snackbar.LENGTH_LONG);
// Get the Snackbar's layout view
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
// Hide the text
TextView textView = (TextView) layout.findViewById(android.support.design.R.id.snackbar_text);
textView.setVisibility(View.INVISIBLE);

// Inflate our custom view
View snackView = mInflater.inflate(R.layout.my_snackbar, null);
// Configure the view
ImageView imageView = (ImageView) snackView.findViewById(R.id.image);
imageView.setImageBitmap(image);
TextView textViewTop = (TextView) snackView.findViewById(R.id.text);
textViewTop.setText(text);
textViewTop.setTextColor(Color.WHITE);

// Add the view to the Snackbar's layout
layout.addView(snackView, 0);
// Show the Snackbar
snackbar.show();

代码示例来源:origin: H07000223/FlycoTabLayout

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
      View tabView = mTabsContainer.getChildAt(i);
      tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
      TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
      tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
      tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
//            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
      if (mTextAllCaps) {
        tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
      }

      if (mTextBold == TEXT_BOLD_BOTH) {
        tv_tab_title.getPaint().setFakeBoldText(true);
      } else if (mTextBold == TEXT_BOLD_NONE) {
        tv_tab_title.getPaint().setFakeBoldText(false);
      }
    }
  }

代码示例来源:origin: Bilibili/DanmakuFlameMaster

@Override
public void onBindViewHolder(int viewType, MyViewHolder viewHolder, BaseDanmaku danmaku, AndroidDisplayer.DisplayerConfig displayerConfig, TextPaint paint) {
  if (paint != null)
    viewHolder.mText.getPaint().set(paint);
  viewHolder.mText.setText(danmaku.text);
  viewHolder.mText.setTextColor(danmaku.textColor);
  viewHolder.mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, danmaku.textSize);
  Bitmap bitmap = null;
  MyImageWare imageWare = (MyImageWare) danmaku.tag;
  if (imageWare != null) {
    bitmap = imageWare.bitmap;
    if (danmaku.text.toString().contains("textview")) {
      Log.e("DFM", "onBindViewHolder======> bitmap:" + (bitmap == null) + "  " + danmaku.tag + "url:" + imageWare.getImageUri());
    }
  }
  if (bitmap != null) {
    viewHolder.mIcon.setImageBitmap(bitmap);
    if (danmaku.text.toString().contains("textview")) {
      Log.e("DFM", "onBindViewHolder======>" + danmaku.tag + "url:" + imageWare.getImageUri());
    }
  } else {
    viewHolder.mIcon.setImageResource(R.drawable.ic_launcher);
  }
}

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

mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

   @Override
   public View getInfoWindow(Marker arg0) {
     return null;
   }

   @Override
   public View getInfoContents(Marker marker) {

    LinearLayout info = new LinearLayout(mContext);
    info.setOrientation(LinearLayout.VERTICAL);

    TextView title = new TextView(mContext);
    title.setTextColor(Color.BLACK);
    title.setGravity(Gravity.CENTER);
    title.setTypeface(null, Typeface.BOLD);
    title.setText(marker.getTitle());

    TextView snippet = new TextView(mContext);
    snippet.setTextColor(Color.GRAY);
    snippet.setText(marker.getSnippet());

    info.addView(title);
    info.addView(snippet);

   return info;
  }
});

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

TextView textview = new TextView(context);
   textview.setText(text);
   textview.setBackgroundColor(Color.GRAY);
   textview.setTextColor(Color.BLUE);
   textview.setPadding(10,10,10,10);
   Toast toast = new Toast(context);
   toast.setView(textview);
   toast.setDuration(Toast.LENGTH_LONG);
   toast.setGravity(Gravity.BOTTOM, 0, 0);
   toast.show();

代码示例来源:origin: bluejamesbond/TextJustify-Android

@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = super.getView(position, convertView, parent);
    TextView textView = (TextView) view.findViewById(android.R.id.text1);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setBackgroundColor(Color.parseColor("#111111"));
    textView.setTextColor(Color.WHITE);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    return view;
  }
});

代码示例来源:origin: navasmdc/MaterialDesignLibrary

@Override
protected void onCreate(Bundle savedInstanceState) {
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.number_indicator_spinner);
  setCanceledOnTouchOutside(false);
  RelativeLayout content = (RelativeLayout) this
      .findViewById(R.id.number_indicator_spinner_content);
  indicator = new Indicator(this.getContext());
  content.addView(indicator);
  numberIndicator = new TextView(getContext());
  numberIndicator.setTextColor(Color.WHITE);
  numberIndicator.setGravity(Gravity.CENTER);
  content.addView(numberIndicator);
  indicator.setLayoutParams(new RelativeLayout.LayoutParams(
      RelativeLayout.LayoutParams.FILL_PARENT,
      RelativeLayout.LayoutParams.FILL_PARENT));
}

代码示例来源:origin: JohnPersano/SuperToasts

private void updateTabStyles() {
  for (int i = 0; i < tabCount; i++) {
    View v = tabsContainer.getChildAt(i);
    v.setBackgroundResource(tabBackgroundResId);
    if (v instanceof TextView) {
      TextView tab = (TextView) v;
      tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
      int tabTypefaceStyle = Typeface.BOLD;
      tab.setTypeface(tabTypeface, tabTypefaceStyle);
      tab.setTextColor(i == currentPosition ? tabTextColor : tabDeactivateTextColor);
    }
  }
}

代码示例来源:origin: hackware1993/MagicIndicator

@Override
public Object instantiateItem(ViewGroup container, int position) {
  TextView textView = new TextView(container.getContext());
  textView.setText(mDataList.get(position));
  textView.setGravity(Gravity.CENTER);
  textView.setTextColor(Color.BLACK);
  textView.setTextSize(24);
  container.addView(textView);
  return textView;
}

代码示例来源:origin: liaoinstan/SpringView

@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    TextView item_text;
    if (convertView == null) {
      convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item, parent, false);
      item_text = convertView.findViewById(R.id.item_text);
      convertView.setTag(item_text);
    } else {
      item_text = (TextView) convertView.getTag();
    }
    if (position % 2 == 1) {
      item_text.setBackgroundColor(Color.parseColor("#e3f1fc"));
      item_text.setTextColor(Color.parseColor("#9dd2fc"));
    } else {
      item_text.setBackgroundColor(Color.parseColor("#ffffff"));
      item_text.setTextColor(Color.parseColor("#cccccc"));
    }
    item_text.setText(results.get(position));
    return convertView;
  }
}

代码示例来源:origin: H07000223/FlycoTabLayout

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
      View v = mTabsContainer.getChildAt(i);
//            v.setPadding((int) mTabPadding, v.getPaddingTop(), (int) mTabPadding, v.getPaddingBottom());
      TextView tv_tab_title = (TextView) v.findViewById(R.id.tv_tab_title);
      if (tv_tab_title != null) {
        tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
        tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
        tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
        if (mTextAllCaps) {
          tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
        }

        if (mTextBold == TEXT_BOLD_BOTH) {
          tv_tab_title.getPaint().setFakeBoldText(true);
        } else if (mTextBold == TEXT_BOLD_NONE) {
          tv_tab_title.getPaint().setFakeBoldText(false);
        }
      }
    }
  }

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

View view = snack.getView();
TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
tv.setTextColor(Color.WHITE);

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Override
public void onTransitionResume(@NonNull Transition transition) {
  if (mChangeBehavior != CHANGE_BEHAVIOR_IN) {
    view.setText(startText);
    if (view instanceof EditText) {
      setSelection(((EditText) view), startSelectionStart, startSelectionEnd);
    }
  }
  if (mChangeBehavior > CHANGE_BEHAVIOR_KEEP) {
    view.setTextColor(mPausedColor);
  }
}

代码示例来源:origin: gzu-liyujiang/AndroidPicker

protected TextView createLabelView() {
  TextView labelView = new TextView(activity);
  labelView.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
  labelView.setTextColor(labelTextColor);
  labelView.setTextSize(textSize);
  return labelView;
}

代码示例来源:origin: jeasonlzy/ImagePicker

@Override
public View getView(int position, View convertView, ViewGroup parent) {
  if (null == convertView) {
    viewholder=new Viewholder();
    convertView=layoutInflater.inflate(R.layout.view_dialog_item, null);
    viewholder.dialogItemButton=(TextView) convertView.findViewById(R.id.dialog_item_bt);
    convertView.setTag(viewholder);
  }else{
    viewholder=(Viewholder) convertView.getTag();
  }
  viewholder.dialogItemButton.setText(mStrings.get(position));
  if (!mUseCustomColor) {
    mFirstItemColor = mActivity.getResources().getColor(R.color.blue);
    mOtherItemColor = mActivity.getResources().getColor(R.color.blue);
  }
  if (1 == mStrings.size()) {
    viewholder.dialogItemButton.setTextColor(mFirstItemColor);
    viewholder.dialogItemButton.setBackgroundResource(R.drawable.dialog_item_bg_only);
  } else if (position == 0) {
    viewholder.dialogItemButton.setTextColor(mFirstItemColor);
    viewholder.dialogItemButton.setBackgroundResource(R.drawable.select_dialog_item_bg_top);
  } else if (position == mStrings.size() - 1) {
    viewholder.dialogItemButton.setTextColor(mOtherItemColor);
    viewholder.dialogItemButton.setBackgroundResource(R.drawable.select_dialog_item_bg_buttom);
  } else {
    viewholder.dialogItemButton.setTextColor(mOtherItemColor);
    viewholder.dialogItemButton.setBackgroundResource(R.drawable.select_dialog_item_bg_center);
  }
  return convertView;
}

代码示例来源:origin: H07000223/FlycoTabLayout

View tabView = mTabsContainer.getChildAt(i);
tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
  tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
if (mIconVisible) {
  iv_tab_icon.setVisibility(View.VISIBLE);

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

Snackbar snackbar;
snackbar = Snackbar.make(view, "Message", Snackbar.LENGTH_SHORT);
View snackBarView = snackbar.getView();
snackBarView.setBackgroundColor(yourColor);
TextView textView = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(textColor);
snackbar.show();

相关文章

TextView类方法