本文整理了Java中android.widget.TextView.setCompoundDrawables()
方法的一些代码示例,展示了TextView.setCompoundDrawables()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setCompoundDrawables()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setCompoundDrawables
暂无
代码示例来源:origin: JessYanCoding/MVPArms
/**
* 设置左边的drawable
*
* @param tv
* @param drawable
*/
public static void setLeftDrawable(TextView tv, Drawable drawable) {
tv.setCompoundDrawables(drawable, null, null, null);
}
代码示例来源:origin: hidroh/materialistic
public void reset() {
if (!mIsLocal) {
mRankTextView.setText(R.string.loading_text);
mScoreTextView.setText(R.string.loading_text);
mScoreTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
mBookmarked.setVisibility(INVISIBLE);
}
mTitleTextView.setText(getContext().getString(R.string.loading_text));
mPostedTextView.setText(R.string.loading_text);
mSourceTextView.setText(R.string.loading_text);
mSourceTextView.setCompoundDrawables(null, null, null, null);
mCommentButton.setVisibility(View.INVISIBLE);
}
代码示例来源:origin: Rukey7/MvpApp
public void hideErrorIcon() {
mTvEmptyMessage.setCompoundDrawables(null, null, null, null);
}
代码示例来源:origin: seven332/EhViewer
private void setActionDrawable(TextView text, Drawable drawable) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
text.setCompoundDrawables(null, drawable, null, null);
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
/**
* 左图标
*
* @param id
*/
public void setLeftImagSrc(int id) {
ivBack.setCompoundDrawables(getResources().getDrawable(id),null,null,null);
}
/**
代码示例来源:origin: smuyyh/BookReader
@Override
public void convert(EasyLVHolder holder, int position, BookMixAToc.mixToc.Chapters chapters) {
TextView tvTocItem = holder.getView(R.id.tvTocItem);
tvTocItem.setText(chapters.title);
Drawable drawable;
if (currentChapter == position + 1) {
tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_red));
drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_activated);
} else if (isEpub || FileUtils.getChapterFile(bookId, position + 1).length() > 10) {
tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_black));
drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_download);
} else {
tvTocItem.setTextColor(ContextCompat.getColor(mContext, R.color.light_black));
drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_toc_item_normal);
}
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
tvTocItem.setCompoundDrawables(drawable, null, null, null);
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置右边view的drawableBottom
*
* @param drawableBottom 资源
* @return 返回
*/
public CommonTextView setRightDrawableBottom(Drawable drawableBottom) {
if (drawableBottom != null) {
drawableBottom.setBounds(0, 0, drawableBottom.getMinimumWidth(), drawableBottom.getMinimumHeight());
}
if (rightTextView == null) {
initRightText();
}
rightTextView.setCompoundDrawables(null, null, null, drawableBottom);
return this;
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置左边view的drawableLeft
*
* @param drawableLeft 资源
* @return 返回
*/
public CommonTextView setLeftDrawableLeft(Drawable drawableLeft) {
if (drawableLeft != null) {
drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
}
if (leftTextView == null) {
initLeftText();
}
leftTextView.setCompoundDrawables(drawableLeft, null, null, null);
return this;
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置左边view的drawableTop
*
* @param drawableTop 资源
* @returnTop 返回
*/
public CommonTextView setLeftDrawableTop(Drawable drawableTop) {
if (drawableTop != null) {
drawableTop.setBounds(0, 0, drawableTop.getMinimumWidth(), drawableTop.getMinimumHeight());
}
if (leftTextView == null) {
initLeftText();
}
leftTextView.setCompoundDrawables(null, drawableTop, null, null);
return this;
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置左边view的drawableRight
*
* @param drawableRight 资源
* @return 返回
*/
public CommonTextView setLeftDrawableRight(Drawable drawableRight) {
if (drawableRight != null) {
drawableRight.setBounds(0, 0, drawableRight.getMinimumWidth(), drawableRight.getMinimumHeight());
}
if (leftTextView == null) {
initLeftText();
}
leftTextView.setCompoundDrawables(null, null, drawableRight, null);
return this;
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置左边view的drawableBottom
*
* @param drawableBottom 资源
* @return 返回
*/
public CommonTextView setLeftDrawableBottom(Drawable drawableBottom) {
if (drawableBottom != null) {
drawableBottom.setBounds(0, 0, drawableBottom.getMinimumWidth(), drawableBottom.getMinimumHeight());
}
if (leftTextView == null) {
initLeftText();
}
leftTextView.setCompoundDrawables(null, null, null, drawableBottom);
return this;
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置中间view的drawableLeft
*
* @param drawableLeft 资源
* @return 返回
*/
public CommonTextView setCenterDrawableLeft(Drawable drawableLeft) {
if (drawableLeft != null) {
drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
}
if (centerTextView == null) {
initCenterText();
}
centerTextView.setCompoundDrawables(drawableLeft, null, null, null);
return this;
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置右边view的drawableLeft
*
* @param drawableLeft 资源
* @return 返回
*/
public CommonTextView setRightDrawableLeft(Drawable drawableLeft) {
if (drawableLeft != null) {
drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
}
if (rightTextView == null) {
initRightText();
}
rightTextView.setCompoundDrawables(drawableLeft, null, null, null);
return this;
}
代码示例来源:origin: lygttpod/SuperTextView
/**
* 设置右边view的drawableRight
*
* @param drawableRight 资源
* @return 返回
*/
public CommonTextView setRightDrawableRight(Drawable drawableRight) {
if (drawableRight != null) {
drawableRight.setBounds(0, 0, drawableRight.getMinimumWidth(), drawableRight.getMinimumHeight());
}
if (rightTextView == null) {
initRightText();
}
rightTextView.setCompoundDrawables(null, null, drawableRight, null);
return this;
}
代码示例来源:origin: yanzhenjie/NoHttp
public static void setLeftDrawable(TextView textView, Drawable leftDrawable) {
setDrawableBounds(leftDrawable);
Drawable top = textView.getCompoundDrawables()[1];
Drawable right = textView.getCompoundDrawables()[2];
Drawable bottom = textView.getCompoundDrawables()[3];
textView.setCompoundDrawables(leftDrawable, top, right, bottom);
}
代码示例来源:origin: yanzhenjie/NoHttp
public static void setBottomDrawable(TextView textView, Drawable bottomDrawable) {
setDrawableBounds(bottomDrawable);
Drawable left = textView.getCompoundDrawables()[0];
Drawable top = textView.getCompoundDrawables()[1];
Drawable right = textView.getCompoundDrawables()[2];
textView.setCompoundDrawables(left, top, right, bottomDrawable);
}
代码示例来源:origin: yanzhenjie/NoHttp
public static void setCompoundDrawables(TextView textView,
Drawable leftDrawable,
Drawable topDrawable,
Drawable rightDrawable,
Drawable bottomDrawable) {
setDrawableBounds(leftDrawable);
setDrawableBounds(topDrawable);
setDrawableBounds(rightDrawable);
setDrawableBounds(bottomDrawable);
textView.setCompoundDrawables(leftDrawable, topDrawable, rightDrawable, bottomDrawable);
}
代码示例来源:origin: yanzhenjie/NoHttp
public static void setTopDrawable(TextView textView, Drawable topDrawable) {
setDrawableBounds(topDrawable);
Drawable left = textView.getCompoundDrawables()[0];
Drawable right = textView.getCompoundDrawables()[2];
Drawable bottom = textView.getCompoundDrawables()[3];
textView.setCompoundDrawables(left, topDrawable, right, bottom);
}
代码示例来源:origin: yanzhenjie/NoHttp
public static void setRightDrawable(TextView textView, Drawable rightDrawable) {
setDrawableBounds(rightDrawable);
Drawable left = textView.getCompoundDrawables()[0];
Drawable top = textView.getCompoundDrawables()[1];
Drawable bottom = textView.getCompoundDrawables()[3];
textView.setCompoundDrawables(left, top, rightDrawable, bottom);
}
代码示例来源:origin: naman14/Timber
public void setEmptyView(Context context, View emptyView, String text) {
this.emptyView = emptyView;
((TextView) emptyView).setText(text);
MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(context)
.setIcon(MaterialDrawableBuilder.IconValue.MUSIC_NOTE)
.setColor(Config.textColorPrimary(context, Helpers.getATEKey(context)))
.setSizeDp(30);
((TextView) emptyView).setCompoundDrawables(null, builder.build(), null, null);
}
}
内容来源于网络,如有侵权,请联系作者删除!