當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.getCompoundDrawables方法代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:23,代碼來源:StatusDataSetter.java

示例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));
    }

}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:26,代碼來源:QMUITabSegment.java

示例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));
    }
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:19,代碼來源:StatusDataSetter.java

示例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;
}
 
開發者ID:Wan7451,項目名稱:mvparms,代碼行數:19,代碼來源:DrawableProvider.java

示例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;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:13,代碼來源:Workspace.java

示例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;
}
 
開發者ID:devzwy,項目名稱:NeiHanDuanZiTV,代碼行數:19,代碼來源:DrawableProvider.java

示例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);
                }
            }
        }

    }
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:28,代碼來源:MySheetsController.java

示例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);
}
 
開發者ID:Superingxz,項目名稱:MoligyMvpArms,代碼行數:18,代碼來源:DrawableProvider.java

示例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);
}
 
開發者ID:Superingxz,項目名稱:MoligyMvpArms,代碼行數:17,代碼來源:DrawableProvider.java

示例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];
}
 
開發者ID:cuongloveit,項目名稱:topsnackbar,代碼行數:9,代碼來源:RightDrawableOnTouchListener.java

示例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]);
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:15,代碼來源:CompoundDrawableUtil.java

示例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);
        }
    }
}
 
開發者ID:vpaliyX,項目名稱:Melophile,代碼行數:10,代碼來源:PresentationUtils.java

示例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;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:5,代碼來源:FolderIcon.java


注:本文中的android.widget.TextView.getCompoundDrawables方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。