android.widget.ImageView.setImageTintList()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(591)

本文整理了Java中android.widget.ImageView.setImageTintList()方法的一些代码示例,展示了ImageView.setImageTintList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setImageTintList()方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:setImageTintList

ImageView.setImageTintList介绍

暂无

代码示例

代码示例来源:origin: HotBitmapGG/bilibili-android-client

private void setWeekDayIconAndTitle(HeaderViewHolder headerViewHolder, int iconRes, String title) {
  if (date.equals(WeekDayUtil.formatDate(DateUtil.getCurrentTime("yyyy-MM-dd")))) {
    headerViewHolder.mUpdateTime.setText("今天");
    headerViewHolder.mUpdateTime.setTextColor(
        mContext.getResources().getColor(R.color.colorPrimary));
    headerViewHolder.mWeekDayText.setTextColor(
        mContext.getResources().getColor(R.color.colorPrimary));
    headerViewHolder.mWeekDayIcon.setImageTintList(
        ColorStateList.valueOf(mContext.getResources().getColor(R.color.colorPrimary)));
  } else {
    headerViewHolder.mUpdateTime.setText(date);
    headerViewHolder.mUpdateTime.setTextColor(
        mContext.getResources().getColor(R.color.black_alpha_30));
    headerViewHolder.mWeekDayText.setTextColor(mContext.getResources().getColor(R.color.gray_80));
    headerViewHolder.mWeekDayIcon.setImageTintList(
        ColorStateList.valueOf(mContext.getResources().getColor(R.color.gray_80)));
  }
  headerViewHolder.mWeekDayIcon.setImageResource(iconRes);
  headerViewHolder.mWeekDayText.setText(title);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@SuppressLint("SetTextI18n")
private void setLive() {
  int roomStatus = mUserLiveRoomStatusInfo.getData().getRoomStatus();
  if (roomStatus == 0) {
    //用户没有直播
    liveImage.setImageResource(R.drawable.ic_live_line);
    liveImage.setImageTintList(ColorStateList.valueOf(getActivity().getResources().getColor(R.color.font_normal)));
    liveStatusTv.setText(R.string.live_message);
    liveStatusTv.setTextColor(getActivity().getResources().getColor(R.color.font_normal));
  } else {
    //用户正在直播
    liveImage.setImageResource(R.drawable.ic_live_fill);
    liveImage.setImageTintList(ColorStateList.valueOf(getActivity().getResources().getColor(R.color.colorPrimary)));
    liveStatusTv.setText("正在直播 :" + mUserLiveRoomStatusInfo.getData().getTitle());
    liveStatusTv.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));
  }
}

代码示例来源:origin: julian-klode/dns66

stateImage.setContentDescription(rootView.getContext().getString(AdVpnService.vpnStatusToTextId(status)));
stateImage.setImageAlpha(255);
stateImage.setImageTintList(ContextCompat.getColorStateList(context, R.color.colorStateImage));
switch(status) {
  case AdVpnService.VPN_STATUS_RECONNECTING:
    stateImage.setImageDrawable(context.getDrawable(R.mipmap.app_icon_large));
    stateImage.setImageAlpha(32);
    stateImage.setImageTintList(null);
    startButton.setText(R.string.action_start);
    break;

代码示例来源:origin: philliphsu/NumberPadTimePicker

@Override
public NumberPadTimePickerThemer setDivider(Drawable divider) {
  mDivider.setImageDrawable(divider);
  if (Build.VERSION.SDK_INT >= 21) {
    // Clear the tint set in the header's layout resource.
    // This is not necessary for pre-21, because the tint
    // doesn't show up when the divider is changed.
    mDivider.setImageTintList(null);
  }
  return this;
}

代码示例来源:origin: ymback/NGA-CLIENT-VER-OPEN-SOURCE

public void handleUserAvatar(ImageView avatarIV, String url) {
  avatarIV.setImageTintList(null);
  ImageUtils.loadRoundCornerAvatar(avatarIV, url);
}

代码示例来源:origin: stackoverflow.com

if(hasImage)
{
  ColorStateList sColorStatePlaying;
  ColorStateList sColorStateNotPlaying;

  sColorStatePlaying = ColorStateList.valueOf(context.getResources().getColor(R.color.colorPrimary));
  AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.anim_current_song);
  ImageView EQ_ANIM = (ImageView) view.findViewById(R.id.imageView_eq_animation);
  EQ_ANIM.setVisibility(View.VISIBLE);
  EQ_ANIM.setImageDrawable(animation);
  EQ_ANIM.setImageTintList(sColorStatePlaying);
  animation.start();
}
else
{
  // Set the default image
}

代码示例来源:origin: AriesHoo/UIWidget

private void setImageTint(ImageView imageView, ColorStateList tint, PorterDuff.Mode tintMode) {
  if (imageView.getDrawable() == null) {
    return;
  }
  if (tint == null && tintMode == null) {
    return;
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    if (mActionTint != null) {
      imageView.setImageTintList(mActionTint);
    }
    if (mActionTintMode != null) {
      imageView.setImageTintMode(mActionTintMode);
    }
  } else {
    Drawable drawable = imageView.getDrawable();
    if (drawable != null && mActionTint != null) {
      drawable = drawable.mutate();
      drawable.setColorFilter(mActionTint.getDefaultColor(), mActionTintMode != null ? mActionTintMode : PorterDuff.Mode.SRC_ATOP);
    }
  }
}

代码示例来源:origin: GreatApo/GreatFit

holder.root.setOnClickListener(iconSetting.onClickListener);
holder.title.setText(iconSetting.title);
holder.icon.setImageTintList(ColorStateList.valueOf(iconSetting.color));

代码示例来源:origin: geniusgithub/AndroidDialer

/**
 * Set drawable resources directly for the drawable resource of the photo view.
 *
 * @param drawableId Id of drawable resource.
 */
public void setDrawableResource(int drawableId) {
  ImageView photo = getPhotoView();
  photo.setScaleType(ImageView.ScaleType.CENTER);
  final Drawable drawable = ContextCompat.getDrawable(getContext(), drawableId);
  final int iconColor =
      ContextCompat.getColor(getContext(), R.color.search_shortcut_icon_color);
  if (CompatUtils.isLollipopCompatible()) {
    photo.setImageDrawable(drawable);
    photo.setImageTintList(ColorStateList.valueOf(iconColor));
  } else {
    final Drawable drawableWrapper = DrawableCompat.wrap(drawable).mutate();
    DrawableCompat.setTint(drawableWrapper, iconColor);
    photo.setImageDrawable(drawableWrapper);
  }
}

代码示例来源:origin: codekidX/storage-chooser

mNewFolderImageView.setImageTintList(ColorStateList.valueOf(scheme[Theme.SEC_ADDRESS_TINT_INDEX]));
mBackButton.setImageTintList(ColorStateList.valueOf(scheme[Theme.SEC_ADDRESS_TINT_INDEX]));

代码示例来源:origin: yoyiyi/bilisoleil

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setWeekData(ViewHolder holder, int iconRes) {
  Date nowDate = com.yoyiyi.soleil.utils.time.TimeUtils.getNowDate();
  String date2String = com.yoyiyi.soleil.utils.time.TimeUtils.date2String(nowDate, new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()));
  if (TextUtils.equals(mDate, date2String /*TimeUtils.formatDate(TimeUtils.getCurrentTime("yyyy-MM-dd")))*/)) {
    holder.setText(R.id.tv_date, "今天")
        .setTextColor(R.id.tv_date, AppUtils.getColor(R.color.colorPrimary))
        .setTextColor(R.id.tv_title, AppUtils.getColor(R.color.colorPrimary));
    ImageView icon = holder.getView(R.id.iv_icon);
    icon.setImageTintList(ColorStateList.valueOf(AppUtils.getColor(R.color.colorPrimary)));
  } else {
    holder.setText(R.id.tv_date, mDate)
        .setTextColor(R.id.tv_date, AppUtils.getColor(R.color.black_alpha_30))
        .setTextColor(R.id.tv_title, AppUtils.getColor(R.color.gray_80));
    ImageView icon = holder.getView(R.id.iv_icon);
    icon.setImageTintList(ColorStateList.valueOf(AppUtils.getColor(R.color.gray_80)));
  }
  holder.setImageResource(R.id.iv_icon, iconRes)
      .setText(R.id.tv_title, mWeek);
}

相关文章

ImageView类方法