本文整理匯總了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;
}