本文整理了Java中android.widget.TextView.setBackgroundResource()
方法的一些代码示例,展示了TextView.setBackgroundResource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setBackgroundResource()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setBackgroundResource
暂无
代码示例来源:origin: iMeiji/Toutiao
/**
* item 被选中时
*/
@Override
public void onItemSelected() {
textView.setBackgroundResource(R.color.textColorPrimary);
}
代码示例来源:origin: iMeiji/Toutiao
/**
* item 取消选中时
*/
@Override
public void onItemFinish() {
textView.setBackgroundResource(R.color.viewBackground);
}
}
代码示例来源:origin: stackoverflow.com
TextView v = (TextView) findViewById(R.id.my_text_view);
v.setBackgroundResource(R.drawable.bg_blue);
代码示例来源:origin: Naoki2015/CircleDemo
public void setTitleBackground(int resid) {
mCenterText.setBackgroundResource(resid);
}
代码示例来源:origin: stackoverflow.com
TextView test = (TextView) view.findViewById(R.id.textView2);
test.setBackgroundResource(context.getResources().getColor(android.R.color.holo_green_light));
代码示例来源:origin: dongjunkun/DropDownMenu
private void fillValue(int position, ViewHolder viewHolder) {
viewHolder.mText.setText(list.get(position));
if (checkItemPosition != -1) {
if (checkItemPosition == position) {
viewHolder.mText.setTextColor(context.getResources().getColor(R.color.drop_down_selected));
viewHolder.mText.setBackgroundResource(R.drawable.check_bg);
} else {
viewHolder.mText.setTextColor(context.getResources().getColor(R.color.drop_down_unselected));
viewHolder.mText.setBackgroundResource(R.drawable.uncheck_bg);
}
}
}
代码示例来源:origin: dongjunkun/DropDownMenu
private void fillValue(int position, ViewHolder viewHolder) {
viewHolder.mText.setText(list.get(position));
if (checkItemPosition != -1) {
if (checkItemPosition == position) {
viewHolder.mText.setTextColor(context.getResources().getColor(R.color.drop_down_selected));
viewHolder.mText.setBackgroundResource(R.color.check_bg);
} else {
viewHolder.mText.setTextColor(context.getResources().getColor(R.color.drop_down_unselected));
viewHolder.mText.setBackgroundResource(R.color.white);
}
}
}
代码示例来源:origin: stackoverflow.com
TextView txtTab = new TextView(this);
XmlResourceParser xrp = getResources().getXml(R.drawable.tab_text_selector);
try {
ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp);
txtTab.setTextColor(csl);
} catch (Exception e) { }
txtTab.setBackgroundResource(R.drawable.tab_bg_selector);
txtTab.setGravity(Gravity.CENTER);
txtTab.setText("Agregar Idea");
代码示例来源:origin: pockethub/PocketHub
/**
* Style view for line
*
* @param line
* @param view
*/
public void updateColors(final CharSequence line, final TextView view) {
if (TextUtils.isEmpty(line)) {
view.setBackgroundResource(R.drawable.list_item_background);
view.setTextColor(defaultColor);
return;
}
switch (line.charAt(0)) {
case '@':
view.setBackgroundResource(R.drawable.diff_marker_background);
view.setTextColor(markerColor);
return;
case '+':
view.setBackgroundResource(R.drawable.diff_add_background);
view.setTextColor(defaultColor);
return;
case '-':
view.setBackgroundResource(R.drawable.diff_remove_background);
view.setTextColor(defaultColor);
return;
default:
view.setBackgroundResource(R.drawable.list_item_background);
view.setTextColor(defaultColor);
}
}
代码示例来源:origin: GitLqr/LQRWeChat
@Override
public void setRecordingTipView() {
if (this.mRecordWindow != null) {
this.mStateIV.setVisibility(View.VISIBLE);
this.mStateIV.setImageResource(R.mipmap.ic_volume_1);
this.mStateTV.setVisibility(View.VISIBLE);
this.mStateTV.setText(R.string.voice_rec);
this.mStateTV.setBackgroundResource(R.drawable.bg_voice_popup);
this.mTimerTV.setVisibility(View.GONE);
}
}
代码示例来源:origin: GitLqr/LQRWeChat
@Override
public void setCancelTipView() {
if (this.mRecordWindow != null) {
this.mTimerTV.setVisibility(View.GONE);
this.mStateIV.setVisibility(View.VISIBLE);
this.mStateIV.setImageResource(R.mipmap.ic_volume_cancel);
this.mStateTV.setVisibility(View.VISIBLE);
this.mStateTV.setText(R.string.voice_cancel);
this.mStateTV.setBackgroundResource(R.drawable.corner_voice_style);
}
}
代码示例来源:origin: GitLqr/LQRWeChat
@Override
public void setTimeoutTipView(int counter) {
if (this.mRecordWindow != null) {
this.mStateIV.setVisibility(View.GONE);
this.mStateTV.setVisibility(View.VISIBLE);
this.mStateTV.setText(R.string.voice_rec);
this.mStateTV.setBackgroundResource(R.drawable.bg_voice_popup);
this.mTimerTV.setText(String.format("%s", new Object[]{Integer.valueOf(counter)}));
this.mTimerTV.setVisibility(View.VISIBLE);
}
}
代码示例来源:origin: aa112901/remusic
@Override
public void setBackgroundResource(int resId) {
if (mBackgroundHelper != null) {
mBackgroundHelper.setBackgroundResId(resId);
} else {
super.setBackgroundResource(resId);
}
}
代码示例来源:origin: AppIntro/AppIntro
/**
* Create a default view to be used for tabs. This is called if a custom tab view is not set via
* {@link #setCustomTabView(int, int)}.
*/
protected TextView createDefaultTabView(Context context) {
TextView textView = new TextView(context);
textView.setGravity(Gravity.CENTER);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
textView.setTypeface(Typeface.DEFAULT_BOLD);
textView.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
TypedValue outValue = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
outValue, true);
textView.setBackgroundResource(outValue.resourceId);
textView.setAllCaps(true);
int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
textView.setPadding(padding, padding, padding, padding);
return textView;
}
代码示例来源:origin: ogaclejapan/SmartTabLayout
textView.setBackgroundResource(tabViewBackgroundResId);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
outValue, true);
textView.setBackgroundResource(outValue.resourceId);
代码示例来源:origin: nex3z/FlowLayout
private TextView buildLabel(String text) {
TextView textView = new TextView(this);
textView.setText(text);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
textView.setPadding((int)dpToPx(16), (int)dpToPx(8), (int)dpToPx(16), (int)dpToPx(8));
textView.setBackgroundResource(R.drawable.label_bg);
return textView;
}
代码示例来源:origin: ankidroid/Anki-Android
/**
* Create a default view to be used for tabs. This is called if a custom tab view is not set via
* {@link #setCustomTabView(int, int)}.
*/
protected TextView createDefaultTabView(Context context) {
TextView textView = new TextView(context);
textView.setGravity(Gravity.CENTER);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
textView.setTypeface(Typeface.DEFAULT_BOLD);
// use the Theme's selectableItemBackground to ensure that the View has a pressed state
TypedValue outValue = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
outValue, true);
textView.setBackgroundResource(outValue.resourceId);
// enable all-caps to match the Action Bar tab style
textView.setAllCaps(true);
int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
textView.setPadding(padding, padding, padding, padding);
return textView;
}
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
/**
* Create a default view to be used for tabs. This is called if a custom tab view is not set via
* {@link #setCustomTabView(int, int)}.
*/
protected TextView createDefaultTabView(Context context) {
TextView textView = new TextView(context);
textView.setGravity(Gravity.CENTER);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
textView.setTypeface(Typeface.DEFAULT_BOLD);
textView.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
TypedValue outValue = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
outValue, true);
textView.setBackgroundResource(outValue.resourceId);
textView.setAllCaps(true);
int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
textView.setPadding(padding, padding, padding, padding);
return textView;
}
代码示例来源:origin: TommyLemon/Android-ZBLibrary
@Override
public void bindView(User data_){
super.bindView(data_ != null ? data_ : new User());
Glide.with(context).asBitmap().load(data.getHead()).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) {
ivUserViewHead.setImageBitmap(CommonUtil.toRoundCorner(bitmap, bitmap.getWidth()/2));
}
});
ivUserViewStar.setImageResource(data.getStarred() ? R.drawable.star_light : R.drawable.star);
tvUserViewSex.setBackgroundResource(data.getSex() == User.SEX_FEMALE
? R.drawable.circle_pink : R.drawable.circle_blue);
tvUserViewSex.setText(data.getSex() == User.SEX_FEMALE ? "女" : "男");
tvUserViewSex.setTextColor(getColor(data.getSex() == User.SEX_FEMALE ? R.color.pink : R.color.blue));
tvUserViewName.setText(StringUtil.getTrimedString(data.getName()));
tvUserViewId.setText("ID:" + data.getId());
tvUserViewNumber.setText("Phone:" + StringUtil.getNoBlankString(data.getPhone()));
}
代码示例来源:origin: TommyLemon/APIJSON
@Override
public void bindView(User data){
if (data == null) {
Log.e(TAG, "bindView data == null >> data = new User(); ");
data = new User();
}
this.data = data;
ImageLoaderUtil.loadImage(ivUserViewHead, data.getHead(), ImageLoaderUtil.TYPE_OVAL);
tvUserViewSex.setBackgroundResource(data.getSex() == User.SEX_FEMALE
? R.drawable.circle_pink : R.drawable.circle_blue);
tvUserViewSex.setText(data.getSex() == User.SEX_FEMALE ? "女" : "男");
tvUserViewSex.setTextColor(getColor(data.getSex() == User.SEX_FEMALE ? R.color.pink : R.color.blue));
tvUserViewName.setText(StringUtil.getTrimedString(data.getName()));
tvUserViewId.setText("ID:" + data.getId());
tvUserViewTag.setText("Tag:" + StringUtil.getTrimedString(data.getTag()));
}
内容来源于网络,如有侵权,请联系作者删除!