本文整理汇总了Java中android.support.v4.graphics.drawable.DrawableCompat.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java DrawableCompat.wrap方法的具体用法?Java DrawableCompat.wrap怎么用?Java DrawableCompat.wrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.graphics.drawable.DrawableCompat
的用法示例。
在下文中一共展示了DrawableCompat.wrap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MyMessageStatusFormatter
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public MyMessageStatusFormatter(Context context) {
//Init icons
mDeliveringIcon = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_mail_outline));
mDeliveredIcon = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_done));
mSeenIcon = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_done_all));
mErrorIcon = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_report));
//Set colors
ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat.getColor(context, R.color.blueGray500));
DrawableCompat.setTintList(mErrorIcon, colorStateList);
DrawableCompat.setTintList(mDeliveringIcon, colorStateList);
DrawableCompat.setTintList(mDeliveredIcon, colorStateList);
DrawableCompat.setTintList(mSeenIcon, colorStateList);
//Init status labels
mDeliveringText = context.getString(R.string.sending);
mDeliveredText = context.getString(R.string.sent);
mSeenText = context.getString(R.string.seen);
mErrorText = context.getString(R.string.error);
}
示例2: init
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void init(final Context context) {
final Drawable drawable = ContextCompat.getDrawable(context, R.mipmap.places_ic_clear);
final Drawable wrappedDrawable = DrawableCompat.wrap(drawable); //Wrap the drawable so that it can be tinted pre Lollipop
DrawableCompat.setTint(wrappedDrawable, getCurrentHintTextColor());
mClearTextIcon = wrappedDrawable;
// mClearTextIcon= context.getResources().getDrawable(R.drawable.icon_delete_32);
mClearTextIcon.setBounds(0, 0, mClearTextIcon.getIntrinsicHeight(), mClearTextIcon.getIntrinsicHeight());
setClearIconVisible(false);
/*
* 设置父类的监听器,还可以单独给该类设置监听器
* */
super.setOnTouchListener(this);
super.setOnFocusChangeListener(this);
addTextChangedListener(this);
}
示例3: init
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void init(final Context context) {
final Drawable drawable = ContextCompat.getDrawable(context, R.drawable.icon_delete_32);
final Drawable wrappedDrawable = DrawableCompat.wrap(drawable); //Wrap the drawable so
// that it can be tinted pre Lollipop
DrawableCompat.setTint(wrappedDrawable, getCurrentHintTextColor());
mClearTextIcon = wrappedDrawable;
// mClearTextIcon= context.getResources().getDrawable(R.drawable.icon_delete_32);
mClearTextIcon.setBounds(0, 0, mClearTextIcon.getIntrinsicHeight(), mClearTextIcon
.getIntrinsicHeight());
setClearIconVisible(false);
super.setOnTouchListener(this);
super.setOnFocusChangeListener(this);
addTextChangedListener(this);
}
示例4: bind
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public void bind(ServerListAdapter adapter, ServerConfigData data) {
mConfigData = data;
Drawable d = DrawableCompat.wrap(mIconBg.getBackground());
DrawableCompat.setTint(d, adapter.mColorInactive);
mIconBg.setBackgroundDrawable(d);
mName.setText(data.name);
}
示例5: onCreateOptionsMenu
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_parse, menu);
for (int c = 0; c < menu.size(); c++) {
MenuItem item = menu.getItem(c);
Drawable drawable = item.getIcon();
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, ContextCompat.getColor(this, R.color.colorAccent));
item.setIcon(drawable);
}
return true;
}
示例6: init
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void init(final Context context) {
final Drawable drawable = ContextCompat.getDrawable(context, R.drawable.svg_delete);
final Drawable wrappedDrawable = DrawableCompat.wrap(drawable); //Wrap the drawable so that it can be tinted pre Lollipop
DrawableCompat.setTint(wrappedDrawable, getCurrentHintTextColor());
mClearTextIcon = wrappedDrawable;
// mClearTextIcon= context.getResources().getDrawable(R.drawable.icon_delete_32);
mClearTextIcon.setBounds(0, 0, mClearTextIcon.getIntrinsicHeight(), mClearTextIcon.getIntrinsicHeight());
setClearIconVisible(false);
super.setOnTouchListener(this);
super.setOnFocusChangeListener(this);
addTextChangedListener(this);
}
示例7: BottomSheetMenuItem
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public BottomSheetMenuItem(MenuItem item,@ColorInt int textColor, @DrawableRes int background,
@ColorInt int tintColor) {
mMenuItem = item;
mIcon = item.getIcon();
mId = item.getItemId();
mTitle = item.getTitle().toString();
mTextColor = textColor;
mBackground = background;
mTintColor = tintColor;
if (mTintColor != -1) {
mIcon = DrawableCompat.wrap(mIcon);
DrawableCompat.setTint(mIcon, mTintColor);
}
}
示例8: setContent
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public void setContent(@DrawableRes int iconResId, @StringRes int titleResId) {
if (iconResId > 0) {
Drawable icon = DrawableCompat.wrap(ContextCompat.getDrawable(getContext(), iconResId));
if (mIconTints != null) {
DrawableCompat.setTintList(icon, mIconTints);
}
((ImageView) findViewById(R.id.icon)).setImageDrawable(icon);
}
((TextView) findViewById(R.id.title)).setText(titleResId);
}
示例9: setIconColor
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public static void setIconColor(ImageView iconHolder, int color) {
Drawable wrappedDrawable = DrawableCompat.wrap(iconHolder.getDrawable());
DrawableCompat.setTint(wrappedDrawable, color);
iconHolder.setImageDrawable(wrappedDrawable);
iconHolder.invalidate();
}
示例10: createTintedDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
@CheckResult
@Nullable
public static Drawable createTintedDrawable(@Nullable Drawable drawable, @NonNull ColorStateList sl) {
if (drawable == null) return null;
drawable = DrawableCompat.wrap(drawable.mutate());
DrawableCompat.setTintList(drawable, sl);
return drawable;
}
示例11: init
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void init(final Context context) {
final Drawable drawable = ContextCompat.getDrawable(context, R.mipmap.ic_delete);
final Drawable wrappedDrawable = DrawableCompat.wrap(drawable); //Wrap the drawable so that it can be tinted pre Lollipop
DrawableCompat.setTint(wrappedDrawable, getCurrentHintTextColor());
mClearTextIcon = wrappedDrawable;
mClearTextIcon.setBounds(0, 0, mClearTextIcon.getIntrinsicHeight(), mClearTextIcon.getIntrinsicHeight());
setClearIconVisible(false);
super.setOnTouchListener(this);
super.setOnFocusChangeListener(this);
addTextChangedListener(this);
}
示例12: setTintColor
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public void setTintColor(@ColorInt int color) {
Drawable drawable = DrawableCompat.wrap(getThumb());
DrawableCompat.setTint(drawable, color);
setThumb(drawable);
drawable = DrawableCompat.wrap(getProgressDrawable());
DrawableCompat.setTint(drawable, color);
setProgressDrawable(drawable);
}
示例13: tintDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public static Drawable tintDrawable(Drawable d, @ColorInt int color) {
Drawable wd = DrawableCompat.wrap(d);
DrawableCompat.setTint(wd, color);
return wd;
}
示例14: initSearchView
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
private void initSearchView() {
SearchView searchView = mBinding.svSearch;
//设置搜索框左边距
LinearLayout editFrame = (LinearLayout) findViewById(R.id.search_edit_frame);
LinearLayout.LayoutParams editP = (LayoutParams) editFrame.getLayoutParams();
editP.leftMargin = 0;
editP.rightMargin = 0;
ImageView imageView = (ImageView) findViewById(R.id.search_mag_icon);
imageView.setAdjustViewBounds(true);
imageView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
LinearLayout.LayoutParams lp3 = (LayoutParams) imageView.getLayoutParams();
lp3.gravity = Gravity.CENTER_VERTICAL;
lp3.leftMargin = (int) (DensityUtil.dip2px(8f) * DensityUtil.getBaseScale(getContext()));
lp3.rightMargin = (int) (DensityUtil.dip2px(-2f) * DensityUtil.getBaseScale(getContext()));
View view = searchView.findViewById(R.id.search_plate);
view.setBackgroundColor(getResources().getColor(R.color.colorTransparent));
EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
editText.setBackgroundColor(Color.TRANSPARENT);
editText.setTextSize(11.5f);
editText.setTextColor(getResources().getColor(R.color.colorText));
editText.setHintTextColor(getResources().getColor(R.color.colorHint));
try {
Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
fCursorDrawableRes.setAccessible(true);
int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
Field fEditor = TextView.class.getDeclaredField("mEditor");
fEditor.setAccessible(true);
Object editor = fEditor.get(editText);
Class<?> clazz = editor.getClass();
Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
fCursorDrawable.setAccessible(true);
if (mCursorDrawableRes <= 0) return;
Drawable cursorDrawable = ContextCompat.getDrawable(searchView.getContext(), mCursorDrawableRes);
if (cursorDrawable == null) return;
Drawable tintDrawable = DrawableCompat.wrap(cursorDrawable);
DrawableCompat.setTintList(tintDrawable, ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.bg_search)));
Drawable[] drawables = new Drawable[]{tintDrawable, tintDrawable};
fCursorDrawable.set(editor, drawables);
} catch (Throwable t) {
t.printStackTrace();
}
}
示例15: tintDrawable
import android.support.v4.graphics.drawable.DrawableCompat; //导入方法依赖的package包/类
public static Drawable tintDrawable(Drawable drawable, ColorStateList colors) {
final Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTintList(wrappedDrawable, colors);
return wrappedDrawable;
}