本文整理了Java中android.widget.ImageView.setImageDrawable()
方法的一些代码示例,展示了ImageView.setImageDrawable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setImageDrawable()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:setImageDrawable
暂无
代码示例来源:origin: novoda/android-demos
private void updateImage() {
boolean useIcon = mMode == Mode.ICON
|| mLogo == null
|| (mMode == Mode.BOTH && !mExpanded);
((ImageView) mView.findViewById(R.id.home)).setImageDrawable(useIcon ? mIcon : mLogo);
}
代码示例来源:origin: MindorksOpenSource/android-mvp-architecture
protected void clear() {
coverImageView.setImageDrawable(null);
titleTextView.setText("");
contentTextView.setText("");
}
代码示例来源:origin: stackoverflow.com
public View getView(int position, View convertView, ViewGroup parent) {
View v;
if (convertView == null) { // if it's not recycled, initialize some attributes
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
v = inflater.inflate(R.layout.gridview_item_layout, parent, false);
} else {
v = (View) convertView;
}
TextView text = (TextView)v.findViewById(R.id.grid_item_text);
text.setText(mTextIds[position]);
ImageView image = (ImageView)v.findViewById(R.id.grid_item_image);
image.setImageDrawable(mThumbIds[position]);
return v;
}
代码示例来源:origin: scwang90/SmartRefreshLayout
mArrowView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsFooter_srlDrawableArrow));
} else {
mArrowDrawable = new ArrowDrawable();
mArrowDrawable.setColor(0xff666666);
mArrowView.setImageDrawable(mArrowDrawable);
mProgressView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsFooter_srlDrawableProgress));
} else {
mProgressDrawable = new ProgressDrawable();
mProgressDrawable.setColor(0xff666666);
mProgressView.setImageDrawable(mProgressDrawable);
mTitleText.setText(thisView.isInEditMode() ? mTextLoading : mTextPulling);
代码示例来源:origin: yarolegovich/SlidingRootNav
@Override
public void bindViewHolder(ViewHolder holder) {
holder.title.setText(title);
holder.icon.setImageDrawable(icon);
holder.title.setTextColor(isChecked ? selectedItemTextTint : normalItemTextTint);
holder.icon.setColorFilter(isChecked ? selectedItemIconTint : normalItemIconTint);
}
代码示例来源:origin: wangdan/AisenWeiBo
private void setNavMenuItemState(int itemId, boolean selected, int selectedColor, int defColor) {
View viewItem = layMenuItems.findViewById(itemId);
NavMenuItem item = (NavMenuItem) viewItem.getTag();
viewItem.setSelected(selected);
ImageView imgIcon = (ImageView) viewItem.findViewById(R.id.icon);
int iconRes = item.iconRes > 0 ? item.iconRes : R.drawable.a_icon_b;
Drawable drawableIcon = DrawableCompat.wrap(ContextCompat.getDrawable(getActivity(), iconRes));
ColorStateList mIconTints = new ColorStateList(
new int[][]{ { android.R.attr.state_selected },
{ } },
new int[]{ selectedColor, defColor });
if (mIconTints != null) {
DrawableCompat.setTintList(drawableIcon, mIconTints);
}
if (item.iconRes > 0) {
imgIcon.setImageDrawable(drawableIcon);
}
TextView txtTitle = (TextView) viewItem.findViewById(R.id.title);
txtTitle.setTextColor(mIconTints);
}
代码示例来源:origin: stackoverflow.com
private View createIndicatorView(TabHost tabHost, CharSequence label, Drawable icon) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View tabIndicator = inflater.inflate(R.layout.tab_indicator,
tabHost.getTabWidget(), // tab widget is the parent
false); // no inflate params
final TextView tv = (TextView) tabIndicator.findViewById(R.id.title);
tv.setText(label);
final ImageView iconView = (ImageView) tabIndicator.findViewById(R.id.icon);
iconView.setImageDrawable(icon);
return tabIndicator;
}
代码示例来源:origin: MindorksOpenSource/android-mvp-architecture
protected void clear() {
coverImageView.setImageDrawable(null);
titleTextView.setText("");
contentTextView.setText("");
}
代码示例来源:origin: scwang90/SmartRefreshLayout
mArrowView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsHeader_srlDrawableArrow));
} else {
mArrowDrawable = new ArrowDrawable();
mArrowDrawable.setColor(0xff666666);
mArrowView.setImageDrawable(mArrowDrawable);
mProgressView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsHeader_srlDrawableProgress));
} else {
mProgressDrawable = new ProgressDrawable();
mProgressDrawable.setColor(0xff666666);
mProgressView.setImageDrawable(mProgressDrawable);
updateView.setVisibility(mEnableLastTime ? VISIBLE : GONE);
centerLayout.addView(updateView, lpUpdateText);
mTitleText.setText(thisView.isInEditMode() ? mTextRefreshing : mTextPulling);
代码示例来源:origin: tyzlmjj/PagerBottomTabStrip
public void initialization(String title, Drawable drawable, Drawable checkedDrawable, boolean tintIcon, int color, int checkedColor) {
mTintIcon = tintIcon;
mDefaultColor = color;
mCheckedColor = checkedColor;
if (mTintIcon) {
mDefaultDrawable = Utils.tinting(drawable, mDefaultColor);
mCheckedDrawable = Utils.tinting(checkedDrawable, mCheckedColor);
} else {
mDefaultDrawable = drawable;
mCheckedDrawable = checkedDrawable;
}
mLabel.setText(title);
mLabel.setTextColor(color);
mIcon.setImageDrawable(mDefaultDrawable);
mAnimator = ValueAnimator.ofFloat(1f);
mAnimator.setDuration(115L);
mAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mAnimatorValue = (float) animation.getAnimatedValue();
if (mHideTitle) {
mIcon.setTranslationY(-mTranslationHideTitle * mAnimatorValue);
} else {
mIcon.setTranslationY(-mTranslation * mAnimatorValue);
}
mLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f + mAnimatorValue * 2f);
}
});
}
代码示例来源:origin: liaoinstan/SpringView
@Override
public View getView(LayoutInflater inflater, ViewGroup viewGroup) {
View view = inflater.inflate(R.layout.meituan_footer, viewGroup, true);
footer_img = (ImageView) view.findViewById(R.id.meituan_footer_img);
if (animationLoading != null)
footer_img.setImageDrawable(animationLoading);
return view;
}
代码示例来源:origin: mikepenz/MaterialDrawer
mAccountHeader = mAccountHeaderContainer.findViewById(R.id.material_drawer_account_header);
mStatusBarGuideline = mAccountHeaderContainer.findViewById(R.id.material_drawer_statusbar_guideline);
mAccountHeaderBackground = mAccountHeaderContainer.findViewById(R.id.material_drawer_account_header_background);
mAccountSwitcherArrow = mAccountHeaderContainer.findViewById(R.id.material_drawer_account_header_text_switcher);
mAccountSwitcherArrow.setImageDrawable(new IconicsDrawable(mActivity, MaterialDrawerFont.Icon.mdf_arrow_drop_down).sizeRes(R.dimen.material_drawer_account_header_dropdown).paddingRes(R.dimen.material_drawer_account_header_dropdown_padding).color(subTextColor));
代码示例来源:origin: android-hacker/VirtualXposed
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.choose_account_row, null);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.account_row_text);
holder.icon = (ImageView) convertView.findViewById(R.id.account_row_icon);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText(mInfos.get(position).name);
holder.icon.setImageDrawable(mInfos.get(position).drawable);
return convertView;
}
}
代码示例来源:origin: mikepenz/FastAdapter
@Override
public void unbindView(ViewHolder holder) {
holder.name.setText(null);
holder.avatar.setImageDrawable(null);
holder.avatar.setVisibility(View.VISIBLE);
holder.icon.setImageDrawable(null);
holder.icon.setVisibility(View.VISIBLE);
}
代码示例来源:origin: aurelhubert/ahbottomnavigation
FrameLayout container = (FrameLayout) view.findViewById(R.id.bottom_navigation_container);
ImageView icon = (ImageView) view.findViewById(R.id.bottom_navigation_item_icon);
TextView title = (TextView) view.findViewById(R.id.bottom_navigation_item_title);
TextView notification = (TextView) view.findViewById(R.id.bottom_navigation_notification);
icon.setImageDrawable(item.getDrawable(context));
title.setText(item.getTitle(context));
iconDrawable = forceTint ? AHHelper.getTintDrawable(items.get(i).getDrawable(context),
current ? itemActiveColor : itemInactiveColor, forceTint) : items.get(i).getDrawable(context);
icon.setImageDrawable(iconDrawable);
title.setTextColor(current ? itemActiveColor : itemInactiveColor);
view.setSoundEffectsEnabled(soundEffectsEnabled);
iconDrawable = forceTint ? AHHelper.getTintDrawable(items.get(i).getDrawable(context),
itemDisableColor, forceTint) : items.get(i).getDrawable(context);
icon.setImageDrawable(iconDrawable);
title.setTextColor(itemDisableColor);
view.setClickable(true);
代码示例来源:origin: arimorty/floatingsearchview
@Override
public void onBindSuggestion(View suggestionView, ImageView leftIcon,
TextView textView, SearchSuggestion item, int itemPosition) {
ColorSuggestion colorSuggestion = (ColorSuggestion) item;
String textColor = mIsDarkSearchTheme ? "#ffffff" : "#000000";
String textLight = mIsDarkSearchTheme ? "#bfbfbf" : "#787878";
if (colorSuggestion.getIsHistory()) {
leftIcon.setImageDrawable(ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_history_black_24dp, null));
Util.setIconColor(leftIcon, Color.parseColor(textColor));
leftIcon.setAlpha(.36f);
} else {
leftIcon.setAlpha(0.0f);
leftIcon.setImageDrawable(null);
}
textView.setTextColor(Color.parseColor(textColor));
String text = colorSuggestion.getBody()
.replaceFirst(mSearchView.getQuery(),
"<font color=\"" + textLight + "\">" + mSearchView.getQuery() + "</font>");
textView.setText(Html.fromHtml(text));
}
代码示例来源:origin: Yalantis/uCrop
/**
* Use {@link #mActiveWidgetColor} for color filter
*/
private void setupStatesWrapper(View view) {
ImageView stateScaleImageView = view.findViewById(R.id.image_view_state_scale);
ImageView stateRotateImageView = view.findViewById(R.id.image_view_state_rotate);
ImageView stateAspectRatioImageView = view.findViewById(R.id.image_view_state_aspect_ratio);
stateScaleImageView.setImageDrawable(new SelectedStateListDrawable(stateScaleImageView.getDrawable(), mActiveWidgetColor));
stateRotateImageView.setImageDrawable(new SelectedStateListDrawable(stateRotateImageView.getDrawable(), mActiveWidgetColor));
stateAspectRatioImageView.setImageDrawable(new SelectedStateListDrawable(stateAspectRatioImageView.getDrawable(), mActiveWidgetColor));
}
代码示例来源:origin: commonsguy/cw-omnibus
private void bindView(int position, View row) {
TextView label=(TextView)row.findViewById(R.id.label);
label.setText(getItem(position).loadLabel(pm));
ImageView icon=(ImageView)row.findViewById(R.id.icon);
icon.setImageDrawable(getItem(position).loadIcon(pm));
}
}
代码示例来源:origin: mikepenz/FastAdapter
@Override
public void unbindView(ViewHolder holder) {
holder.name.setText(null);
holder.description.setText(null);
holder.avatar.setImageDrawable(null);
holder.avatar.setVisibility(View.VISIBLE);
holder.icon.setImageDrawable(null);
holder.icon.setVisibility(View.VISIBLE);
}
代码示例来源:origin: aurelhubert/ahbottomnavigation
ImageView icon = (ImageView) view.findViewById(R.id.bottom_navigation_small_item_icon);
TextView title = (TextView) view.findViewById(R.id.bottom_navigation_small_item_title);
TextView notification = (TextView) view.findViewById(R.id.bottom_navigation_notification);
icon.setImageDrawable(item.getDrawable(context));
title.setText(item.getTitle(context));
iconDrawable = forceTint ? AHHelper.getTintDrawable(items.get(i).getDrawable(context),
currentItem == i ? itemActiveColor : itemInactiveColor, forceTint) : items.get(i).getDrawable(context);
icon.setImageDrawable(iconDrawable);
title.setTextColor(currentItem == i ? itemActiveColor : itemInactiveColor);
title.setAlpha(currentItem == i ? 1 : 0);
iconDrawable = forceTint ? AHHelper.getTintDrawable(items.get(i).getDrawable(context),
itemDisableColor, forceTint) : items.get(i).getDrawable(context);
icon.setImageDrawable(iconDrawable);
title.setTextColor(itemDisableColor);
title.setAlpha(0);
内容来源于网络,如有侵权,请联系作者删除!