当前位置: 首页>>代码示例>>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;未经允许,请勿转载。