當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。