当前位置: 首页>>代码示例>>Java>>正文


Java DrawableCompat.wrap方法代码示例

本文整理汇总了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);
}
 
开发者ID:RRDL,项目名称:CRT,代码行数:20,代码来源:MyMessageStatusFormatter.java

示例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);
    }
 
开发者ID:yiwent,项目名称:Mobike,代码行数:18,代码来源:ClearEditText.java

示例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);
    }
 
开发者ID:gaolhjy,项目名称:cniao5,代码行数:17,代码来源:ClearEditText.java

示例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);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:8,代码来源:ServerListAdapter.java

示例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;
}
 
开发者ID:solkin,项目名称:minion-android,代码行数:13,代码来源:ParseActivity.java

示例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);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:ClearEditText.java

示例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);
    }
}
 
开发者ID:yuhodev,项目名称:login,代码行数:16,代码来源:BottomSheetMenuItem.java

示例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);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:11,代码来源:NavDrawerItemView.java

示例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();
}
 
开发者ID:lurbas,项目名称:ListItemView,代码行数:7,代码来源:ViewUtils.java

示例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;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:9,代码来源:TintHelper.java

示例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);
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:12,代码来源:AppCompatClearEditText.java

示例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);
}
 
开发者ID:hongcwamazing,项目名称:PreviewSeekBar-master,代码行数:10,代码来源:PreviewSeekBar.java

示例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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:6,代码来源:DrawableUtils.java

示例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();
    }
}
 
开发者ID:xieyangxuejun,项目名称:SearchLayout,代码行数:44,代码来源:FlowSearchLayout.java

示例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;
}
 
开发者ID:didikee,项目名称:CommonDependence,代码行数:6,代码来源:UIToast.java


注:本文中的android.support.v4.graphics.drawable.DrawableCompat.wrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。