本文整理了Java中android.widget.TextView.setCompoundDrawablesRelativeWithIntrinsicBounds()
方法的一些代码示例,展示了TextView.setCompoundDrawablesRelativeWithIntrinsicBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setCompoundDrawablesRelativeWithIntrinsicBounds()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setCompoundDrawablesRelativeWithIntrinsicBounds
暂无
代码示例来源:origin: stackoverflow.com
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(images.get(position), 0, 0, 0);
} else {
textView.setCompoundDrawablesWithIntrinsicBounds(images.get(position), 0, 0, 0);
代码示例来源:origin: rey5137/material
if (drawableEnd != null)
drawables[2] = drawableEnd;
v.setCompoundDrawablesRelativeWithIntrinsicBounds(drawables[0], drawables[1], drawables[2], drawables[3]);
代码示例来源:origin: geniusgithub/AndroidDialer
private void updateBlockActionItem() {
if (mBlockedNumberId == null) {
mBlockNumberActionItem.setText(R.string.action_block_number);
mBlockNumberActionItem.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.ic_call_detail_block, 0, 0, 0);
} else {
mBlockNumberActionItem.setText(R.string.action_unblock_number);
mBlockNumberActionItem.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.ic_call_detail_unblock, 0, 0, 0);
}
}
代码示例来源:origin: stackoverflow.com
TextView description = (TextView) findViewById(R.id.description);
description.setText("My cool product");
description.setCompoundDrawablesRelativeWithIntrinsicBounds
(null, R.drawable.product1, null, null);
代码示例来源:origin: student9128/BottomNavigationBarForAndroid
/**
* set the tab state of bottom navigation bar
*
* @param textView the text to be shown
* @param image the image
* @param color the text color
*/
private void setTabState(TextView textView, int image, int color) {
textView.setCompoundDrawablesRelativeWithIntrinsicBounds(0, image, 0, 0);//Call requires API level 17
textView.setTextColor(color);
}
代码示例来源:origin: stackoverflow.com
TextView tvUserName= (TextView)findViewById(R.id.et_username_or_email);
VectorDrawableCompat drawableCompat=VectorDrawableCompat.create(getResources(), R.drawable.layer_list_ic_user, tvUserName.getContext().getTheme());
tvUserName.setCompoundDrawablesRelativeWithIntrinsicBounds(drawableCompat, null, null, null);
代码示例来源:origin: stackoverflow.com
TextView tvUserName= (TextView )view.findViewById(R.id.et_username_or_email);
VectorDrawableCompat drawableCompat=VectorDrawableCompat.create(getActivity().getResources(), R.drawable.layer_list_ic_user, tvUserName.getContext().getTheme());
tvUserName.setCompoundDrawablesRelativeWithIntrinsicBounds(drawableCompat, null, null, null);
代码示例来源:origin: stefan-niedermann/nextcloud-deck
private void themeDueDate(Context context, TextView cardDueDate, @DrawableRes int background, @ColorRes int textColor, @DrawableRes int icon) {
cardDueDate.setBackgroundResource(background);
cardDueDate.setTextColor(context.getResources().getColor(textColor));
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
cardDueDate.setCompoundDrawablesRelativeWithIntrinsicBounds(
context.getResources().getDrawable(icon),
null,
null,
null
);
} else {
cardDueDate.setCompoundDrawablesWithIntrinsicBounds(
context.getResources().getDrawable(icon),
null,
null,
null
);
}
}
代码示例来源:origin: queencodemonkey/loving-lean-layouts
private void setAttribution(Attribution attribution) {
if (attribution == null) {
throw new IllegalArgumentException("Cannot set " + getClass().getName()
+ " with a null attribution.");
}
mAttribution = attribution;
if (attribution.drawableResId != 0) {
mTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(
attribution.drawableResId, 0, 0, 0);
mTextView.setText(attribution.text);
} else {
mTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.ic_font_download_white_36dp, 0, 0, 0);
final SpannableString text = new SpannableString(attribution.text);
final Context context = mTextView.getContext();
final Typeface typeface = TypefaceUtils.load(context.getAssets(),
context.getString(mAttribution.fontPath));
text.setSpan(new CalligraphyTypefaceSpan(typeface),
0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mTextView.setText(text, TextView.BufferType.SPANNABLE);
}
}
代码示例来源:origin: ywwynm/EverythingDone
private void initStartDoingTitle() {
TextView tvTitle = f(R.id.tv_title_group_start_doing_settings);
Drawable d1 = ContextCompat.getDrawable(this, R.drawable.act_start_doing);
Drawable d2 = d1.mutate();
d2.setColorFilter(mAccentColor, PorterDuff.Mode.SRC_ATOP);
if (DeviceUtil.hasJellyBeanMR1Api()) {
tvTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(d2, null, null, null);
} else {
tvTitle.setCompoundDrawablesWithIntrinsicBounds(d2, null, null, null);
}
}
代码示例来源:origin: ywwynm/EverythingDone
@Override
public void onBindViewHolder(StatisticHolder holder, int position) {
if (DeviceUtil.hasJellyBeanMR1Api()) {
holder.tvFirst.setCompoundDrawablesRelativeWithIntrinsicBounds(
mIconRes[position], 0, 0, 0);
} else {
holder.tvFirst.setCompoundDrawablesWithIntrinsicBounds(
mIconRes[position], 0, 0, 0);
}
holder.tvFirst.setText(mFirstRes[position]);
if (mFirstTextSizes == null || mFirstTextSizes.length <= position
|| mFirstTextSizes[position] == 0) {
holder.tvFirst.setTextSize(16);
} else {
holder.tvFirst.setTextSize(mFirstTextSizes[position]);
}
holder.tvSecond.setText(mSecondStrs[position]);
if (position == mIconRes.length - 1) {
holder.vSeparator.setVisibility(View.GONE);
} else {
holder.vSeparator.setVisibility(View.VISIBLE);
}
}
代码示例来源:origin: Sea-n/Android-TG-Bot
@Override
public void onClick(View view) {
if (null == _bots)
_bots = db.getBots();
if (_bots.size() == 0) {
Log.d("main", "no bot");
askAddBot();
return;
}
if (changeAccountMenuOpen) {
restoreMenu();
} else {
menu.setGroupVisible(R.id.menu_api, false);
accountItem.setVisible(true);
changeAccountMenuOpen = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
subtitle.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_up_black_24dp, 0);
}
}
});
代码示例来源:origin: googlesamples/android-AutofillFramework
Drawable mutatedLogoDrawable = logoDrawable.mutate();
mutatedLogoDrawable.setColorFilter(imageColor, PorterDuff.Mode.SRC_IN);
buttonLabel.setCompoundDrawablesRelativeWithIntrinsicBounds(mutatedLogoDrawable, null,
null, null);
代码示例来源:origin: sunfusheng/GroupRecyclerViewAdapter
@Override
public void onBindChildViewHolder(GroupViewHolder holder, DataSource.WeChatItemConfig item, int groupPosition, int childPosition) {
int viewType = getChildItemViewType(groupPosition, childPosition);
if (viewType == DataSource.VIEW_TYPE_WECHAT_PROFILE) {
TextView tvName = holder.get(R.id.tv_wechat_name);
tvName.setText(item.titleId);
holder.setImageResource(R.id.iv_avatar, R.mipmap.ic_me_avatar);
} else {
TextView tvTitle = holder.get(R.id.tv_title);
tvTitle.setText(item.titleId);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
tvTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(item.imgId, 0, 0, 0);
} else {
tvTitle.setCompoundDrawables(context.getResources().getDrawable(item.imgId), null, null, null);
}
}
holder.setVisible(R.id.divider, !isGroupLastItem(groupPosition, childPosition));
}
代码示例来源:origin: Sea-n/Android-TG-Bot
@Override
public void run() {
menu.setGroupVisible(R.id.menu_api, true);
accountItem.setVisible(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
subtitle.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down_black_24dp, 0);
if (null == currentBot) {
Log.d("main", "no bot on restore menu");
askAddBot();
return;
}
switch (currentBot.type) {
case 0:
caller.setEnabled(true);
downloader.setEnabled(true);
break;
case 1:
case 2:
caller.setEnabled(false);
downloader.setEnabled(false);
break;
default:
Log.d("main", "Unknown type " + currentBot.type);
break;
}
}
});
代码示例来源:origin: wuhenzhizao/android-titlebar
tvLeft.setCompoundDrawablePadding((int) leftDrawablePadding);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
tvLeft.setCompoundDrawablesRelativeWithIntrinsicBounds(leftDrawable, 0, 0, 0);
} else {
tvLeft.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, 0, 0, 0);
代码示例来源:origin: Mavamaarten/vk_music_android
void bind(VKApiAudio audio) {
binding.getRoot().setOnClickListener(v -> listener.onAudioClicked(audio, getAdapterPosition()));
binding.audioOptions.setOnClickListener(v -> showPopupMenu(v, audio));
binding.dragHandle.setOnTouchListener((v, event) -> {
if (startDragListener == null) {
return false;
}
startDragListener.startDrag(this);
return true;
});
binding.setAudio(audio);
binding.executePendingBindings();
if (currentAudio == null || audio.id != currentAudio.id) {
binding.audioTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, null);
} else {
binding.audioTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
ResourcesCompat.getDrawable(resources, R.drawable.ic_now_playing_indicator, null),
null,
null,
null
);
}
}
代码示例来源:origin: ywwynm/EverythingDone
@Override
public void onClick(View v) {
boolean isDragging = mCheckListAdapter.isDragging();
if (!isDragging) {
mTvMoveChecklistAsBt.setText(R.string.act_back_from_move_checklist);
if (DeviceUtil.hasJellyBeanMR1Api()) {
mTvMoveChecklistAsBt.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.act_back_from_move_checklist, 0, 0, 0);
} else {
mTvMoveChecklistAsBt.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.act_back_from_move_checklist, 0, 0, 0);
}
mCheckListAdapter.setDragging(true);
mChecklistTouchHelper.attachToRecyclerView(mRvCheckList);
} else {
mTvMoveChecklistAsBt.setText(R.string.act_move_check_list);
if (DeviceUtil.hasJellyBeanMR1Api()) {
mTvMoveChecklistAsBt.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.act_move_checklist, 0, 0, 0);
} else {
mTvMoveChecklistAsBt.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.act_move_checklist, 0, 0, 0);
}
mCheckListAdapter.setDragging(false);
mChecklistTouchHelper.attachToRecyclerView(null);
}
mCheckListAdapter.notifyDataSetChanged();
}
});
代码示例来源:origin: jrvansuita/IconHandler
public void put() {
if (icon == 0 && bitmap == null)
throw new Error("You must provide an icon resource id or a bitmap!");
if (v != null) {
Util.background(v, new SelectorDrawable(v.getContext()));
} else if (iv != null) {
iv.setImageDrawable(new SelectorDrawable(iv.getContext()));
} else if (tv != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
tv.setCompoundDrawablesRelativeWithIntrinsicBounds(getForPosition(Gravity.LEFT), getForPosition(Gravity.TOP), getForPosition(Gravity.RIGHT), getForPosition(Gravity.BOTTOM));
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(getForPosition(Gravity.LEFT), getForPosition(Gravity.TOP), getForPosition(Gravity.RIGHT), getForPosition(Gravity.BOTTOM));
}
} else if (mi != null) {
Context context = Util.getMenuItemContext(mi);
if (context != null)
mi.setIcon(new SelectorDrawable(context));
}
}
内容来源于网络,如有侵权,请联系作者删除!