本文整理匯總了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;
}