本文整理汇总了Java中android.widget.TextView.getCompoundDrawables方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.getCompoundDrawables方法的具体用法?Java TextView.getCompoundDrawables怎么用?Java TextView.getCompoundDrawables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.getCompoundDrawables方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateSuccess
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void onCreateSuccess(boolean lastHeart, long sid, long aid, TextView tvAttitude) {
AttitudeContainer.sHeartContainer.put(sid, aid);
if (lastHeart) {
AppToast.showToast("上次点过赞了");
} else {
String countStr = tvAttitude.getText().toString();
if (TextUtils.isDigitsOnly(countStr)) {
int count = Integer.parseInt(countStr) + 1;
tvAttitude.setText(NumberFormatter.formatWBCount(count, 60000));
}
}
Drawable[] compoundDrawables = tvAttitude.getCompoundDrawables();
if (compoundDrawables[0] != null) {
Drawable drawable = mActivity.getResources().getDrawable(R.drawable.ic_like_press);
// 必须设置图片大小,否则不显示
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
tvAttitude.setCompoundDrawables(drawable, null, null, null);
} else {
tvAttitude.setTextColor(ContextCompat.getColor(mActivity, R.color.colorPrimary));
}
}
示例2: changeTabColor
import android.widget.TextView; //导入方法依赖的package包/类
private void changeTabColor(TextView textView, int color, Tab model, int status, boolean preventColorChange) {
if (!preventColorChange) {
textView.setTextColor(color);
}
if (!model.isDynamicChangeIconColor()) {
if (status == STATUS_NORMAL || model.getSelectedIcon() == null) {
setDrawable(textView, model.getNormalIcon(), getTabIconPosition(model));
} else if (status == STATUS_SELECTED) {
setDrawable(textView, model.getSelectedIcon(), getTabIconPosition(model));
}
return;
}
if (!preventColorChange) {
Drawable drawable = textView.getCompoundDrawables()[getTabIconPosition(model)];
if (drawable == null) {
return;
}
// 这里要拿textView已经set并mutate的drawable
QMUIDrawableHelper.setDrawableTintColor(drawable, color);
setDrawable(textView, model.getNormalIcon(), getTabIconPosition(model));
}
}
示例3: onDestroySuccess
import android.widget.TextView; //导入方法依赖的package包/类
@Override
public void onDestroySuccess(long sid, long aid, TextView tvAttitude) {
AttitudeContainer.sHeartContainer.remove(sid);
Drawable[] compoundDrawables = tvAttitude.getCompoundDrawables();
if (compoundDrawables[0] != null) {
Drawable drawable = mActivity.getResources().getDrawable(R.drawable.ic_like);
// 必须设置图片大小,否则不显示
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
tvAttitude.setCompoundDrawables(drawable, null, null, null);
} else {
tvAttitude.setTextColor(ContextCompat.getColor(mActivity, R.color.retweeted_count_text_color));
}
String countStr = tvAttitude.getText().toString();
if (TextUtils.isDigitsOnly(countStr)) {
int count = Integer.parseInt(countStr) - 1;
tvAttitude.setText(NumberFormatter.formatWBCount(count, 60000));
}
}
示例4: getScaleDrawableForRadioButton2
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 将radiobutton的drawable动态的缩放
*
* @param rb
* @return
*/
public static Drawable getScaleDrawableForRadioButton2(float width, TextView rb) {
Drawable[] compoundDrawables = rb.getCompoundDrawables();
Drawable drawable = null;
for (Drawable d : compoundDrawables) {
if (d != null) {
drawable = d;
}
}
float percent = width * 1.0f / drawable.getIntrinsicWidth();
drawable.setBounds(0, 0, (int) (drawable.getIntrinsicWidth() * percent + 0.5f), (int) (drawable.getIntrinsicHeight() * percent + 0.5f));
return drawable;
}
示例5: getTextViewIcon
import android.widget.TextView; //导入方法依赖的package包/类
/**
* Returns the drawable for the given text view.
*/
public static Drawable getTextViewIcon(TextView tv) {
final Drawable[] drawables = tv.getCompoundDrawables();
for (int i = 0; i < drawables.length; i++) {
if (drawables[i] != null) {
return drawables[i];
}
}
return null;
}
示例6: getScaleDrawableForRadioButton
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 将radiobutton的drawable动态的缩放
*
* @param percent
* @param rb
* @return
*/
public static Drawable getScaleDrawableForRadioButton(float percent, TextView rb) {
Drawable[] compoundDrawables = rb.getCompoundDrawables();
Drawable drawable = null;
for (Drawable d : compoundDrawables) {
if (d != null) {
drawable = d;
}
}
drawable.setBounds(0, 0, (int) (drawable.getIntrinsicWidth() * percent + 0.5f), (int) (drawable.getIntrinsicHeight() * percent + 0.5f));
return drawable;
}
示例7: emptyViewThemeChange
import android.widget.TextView; //导入方法依赖的package包/类
private void emptyViewThemeChange(int[] colors) {
int accentC;
if (colors == null) {
ThemeEnum themeEnum = new AppPreference(activity).getTheme();
int[] cs = ColorUtils.get10ThemeColors(activity, themeEnum);
accentC = cs[2];
} else {
accentC = colors[0];
}
View v = mEmptyListNoticeContainer.getChildAt(EMPTY_VIEW_INDEX);
TextView text = (TextView) v.findViewById(R.id.sheet_empty_add);
text.setTextColor(accentC);
Drawable[] drawables = text.getCompoundDrawables();
for (Drawable d : drawables) {
if (d != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
d.setTint(accentC);
}
}
}
}
示例8: getScaleDrawableForRadioButton
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 将 TextView/RadioButton 中设置的 drawable 动态的缩放
*
* @param percent
* @param tv
* @return
*/
public static Drawable getScaleDrawableForRadioButton(float percent, TextView tv) {
Drawable[] compoundDrawables = tv.getCompoundDrawables();
Drawable drawable = null;
for (Drawable d : compoundDrawables) {
if (d != null) {
drawable = d;
}
}
return getScaleDrawable(percent, drawable);
}
示例9: getScaleDrawableForRadioButton2
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 将 TextView/RadioButton 中设置的 drawable 动态的缩放
*
* @param tv
* @return
*/
public static Drawable getScaleDrawableForRadioButton2(float width, TextView tv) {
Drawable[] compoundDrawables = tv.getCompoundDrawables();
Drawable drawable = null;
for (Drawable d : compoundDrawables) {
if (d != null) {
drawable = d;
}
}
return getScaleDrawable2(width, drawable);
}
示例10: RightDrawableOnTouchListener
import android.widget.TextView; //导入方法依赖的package包/类
public RightDrawableOnTouchListener(TextView view, float sizeClick) {
super();
final Drawable[] drawables = view.getCompoundDrawables();
context = view.getContext();
this.sizeClick = sizeClick;
if (drawables != null && drawables.length == 4)
this.drawable = drawables[2];
}
示例11: changeCompoundDrawableWithPadding
import android.widget.TextView; //导入方法依赖的package包/类
public static void changeCompoundDrawableWithPadding(TextView textView, int where, int resId, int drawablePadding) {
if (where < 0 || where > 3)
return;
if (resId <= 0) {
LogUtils.e("changeCompoundDrawableWithPadding resId = " + resId + " is error.....");
return;
}
Drawable[] drawables = textView.getCompoundDrawables();
Drawable exptectedDrawable = ResouceUtil.getDrawable(resId);
drawables[where] = exptectedDrawable;
textView.setCompoundDrawablePadding(SizeUtils.dp2px(drawablePadding));
textView.setCompoundDrawables(drawables[0], drawables[1], drawables[2], drawables[3]);
}
示例12: setDrawableColor
import android.widget.TextView; //导入方法依赖的package包/类
public static void setDrawableColor(TextView view, int color){
Drawable[] drawables=view.getCompoundDrawables();
for(Drawable drawable:drawables){
if(drawable!=null){
drawable.mutate();
DrawableCompat.setTint(drawable,color);
}
}
}
示例13: getTopDrawable
import android.widget.TextView; //导入方法依赖的package包/类
private Drawable getTopDrawable(TextView v) {
Drawable d = v.getCompoundDrawables()[1];
return (d instanceof PreloadIconDrawable) ? ((PreloadIconDrawable) d).mIcon : d;
}