• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TintableBackgroundView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.support.v4.view.TintableBackgroundView的典型用法代码示例。如果您正苦于以下问题:Java TintableBackgroundView类的具体用法?Java TintableBackgroundView怎么用?Java TintableBackgroundView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TintableBackgroundView类属于android.support.v4.view包,在下文中一共展示了TintableBackgroundView类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setTint

import android.support.v4.view.TintableBackgroundView; //导入依赖的package包/类
public static void setTint(@NonNull EditText editText, @ColorInt int color, boolean useDarker) {
    final ColorStateList editTextColorStateList = new ColorStateList(new int[][]{
            new int[]{-android.R.attr.state_enabled},
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_pressed, -android.R.attr.state_focused},
            new int[]{}
    }, new int[]{
            ContextCompat.getColor(editText.getContext(), useDarker ? R.color.ate_text_disabled_dark : R.color.ate_text_disabled_light),
            ContextCompat.getColor(editText.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
            color
    });
    if (editText instanceof TintableBackgroundView) {
        ViewCompat.setBackgroundTintList(editText, editTextColorStateList);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        editText.setBackgroundTintList(editTextColorStateList);
    }
    setCursorTint(editText, color);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:18,代码来源:TintHelper.java


示例2: setColorFilter

import android.support.v4.view.TintableBackgroundView; //导入依赖的package包/类
@Override
public void setColorFilter(ColorFilter colorFilter) {
    // Check if we should enforce our inner tintList.
    if (mTintList != null) {
        Drawable rootDrawable = getRootDrawable(this);
        View view = getView(rootDrawable);

        if (isTintableBackground(view, rootDrawable)) {
            // TintableBackgroundViews store internal tintLists for known drawables.
            // Those tintLists can become outdated, if they contain attributes that are code-colors.
            // We make sure to store and enforce different tintList every time the code-colors change.
            ColorStateList tintList = ((TintableBackgroundView) view).getSupportBackgroundTintList();
            if (tintList == null) {
                ((TintableBackgroundView) view).setSupportBackgroundTintList(mTintList);
                return;
            }
        }
    }

    // We are not restoring our inner tintList.
    // Apply the color filter normally.
    super.setColorFilter(colorFilter);
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:24,代码来源:CcAppCompatDrawableWrapper.java


示例3: render

import android.support.v4.view.TintableBackgroundView; //导入依赖的package包/类
public void render(@Nullable final SearchSuggestionRVItem item,
                   @Nullable final OnClickListener listener) {
    if (!hasContext() || item == null) {
        return;
    }

    mItem = item;
    if (listener != null) {
        mListener = listener;
    }

    mSuggestionField.setText(item.getSuggestion());

    if (mSuggestionField instanceof TintableBackgroundView) {
        // "AppCompatTextView" and "com.android.support:appcompat-v7" are used, tint all states
        ViewCompat.setBackgroundTintList(mSuggestionField,
                new ColorStateList(STATES, new int[]{
                        AbstractColorUtils.getColor(getContext(), item.getPlaceholder()),
                        AbstractColorUtils.getColor(getContext(), R.color.tenor_sdk_primary_color)}));
        return;
    }

    // "com.android.support:appcompat-v7" is likely not being used, and thus "TextView" is used
    Drawable background = mSuggestionField.getBackground();
    if (background instanceof TintAwareDrawable) {
        // tint all states of the given drawable
        DrawableCompat.setTintList(background,
                new ColorStateList(STATES, new int[]{
                        AbstractColorUtils.getColor(getContext(), item.getPlaceholder()),
                        AbstractColorUtils.getColor(getContext(), R.color.tenor_sdk_primary_color)}));
        return;
    }

    // last option, tint only the background individually
    AbstractDrawableUtils.setDrawableTint(getContext(), background, item.getPlaceholder());
}
 
开发者ID:Tenor-Inc,项目名称:tenor-android-demo-search,代码行数:37,代码来源:SearchSuggestionVH.java


示例4: onAdd

import android.support.v4.view.TintableBackgroundView; //导入依赖的package包/类
@Override
public boolean onAdd(View view, InflateAddResult<View> outResult) {
    if (view instanceof TintableBackgroundView) {
        ColorStateList backgroundTintList = ((TintableBackgroundView) view).getSupportBackgroundTintList();
        if (backgroundTintList instanceof CodeColor) {
            outResult.set(view);
            outResult.add(
                    (CodeColor) backgroundTintList,
                    new TintableBackgroundCallback(backgroundTintList));
            return true;
        }
    }
    return false;
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:15,代码来源:CcTintableBackgroundColorCallbackAdapter.java


示例5: refreshDrawableState

import android.support.v4.view.TintableBackgroundView; //导入依赖的package包/类
private boolean refreshDrawableState(View view) {
    if (((TintableBackgroundView) view).getSupportBackgroundTintList() == mBackgroundTintList) {
        view.refreshDrawableState();
        return true;
    } else {
        return false;
    }
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:9,代码来源:CcTintableBackgroundColorCallbackAdapter.java


示例6: updateTintList

import android.support.v4.view.TintableBackgroundView; //导入依赖的package包/类
protected void updateTintList() {
    if (mUpdateTintList) {
        mUpdateTintList = false;

        Drawable rootDrawable = getRootDrawable(this);
        View view = getView(rootDrawable);
        Context context = getContext(view);
        if (context != null) {
            AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
            // The context wrapper ensures that the manager doesn't reuse old tint lists.
            Context contextWrapper = new ContextWrapper(context);
            ColorStateList tintList = drawableManager.getTintList(contextWrapper, mState.mId);

            if (tintList != null && isTintableBackground(view, rootDrawable)) {
                ColorStateList viewTintList = ((TintableBackgroundView) view).getSupportBackgroundTintList();
                // TintableBackgroundViews store internal tintLists for known drawables.
                // Those tintLists can become outdated, if they contain attributes that are code-colors.
                // We make sure to store and enforce different tintList every time the code-colors change.
                if (viewTintList == null || viewTintList == mTintList) {
                    ((TintableBackgroundView) view).setSupportBackgroundTintList(tintList);
                }
                mTintList = tintList;
            } else {
                // If tint list is null, tintDrawable will still try to set color filters.
                CcTintManager.tintDrawable(context, tintList, mDrawable, mState.mId);
            }
        }
    }
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:30,代码来源:CcAppCompatDrawableWrapper.java


示例7: updateUI

import android.support.v4.view.TintableBackgroundView; //导入依赖的package包/类
private void updateUI() {
    ((Button) this.findViewById(R.id.running_button)).setText((running) ? getResources().getString(R.string.stop) : getResources().getString(R.string.start));
    ((TintableBackgroundView) (Button) this.findViewById(R.id.running_button)).setSupportBackgroundTintList(ColorStateList.valueOf(getResources().getColor((running) ? R.color.colorAccent : R.color.colorPrimary)));
    ((TintableBackgroundView) (Button) this.findViewById(R.id.send_button)).setSupportBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary)));
}
 
开发者ID:micku7zu,项目名称:Locate-driver,代码行数:6,代码来源:MainActivity.java


示例8: isTintableBackground

import android.support.v4.view.TintableBackgroundView; //导入依赖的package包/类
private static boolean isTintableBackground(View view, Drawable rootDrawable) {
    return view instanceof TintableBackgroundView && view.getBackground() == rootDrawable;
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:4,代码来源:CcAppCompatDrawableWrapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InfusionEnchantmentRecipe类代码示例发布时间:2022-05-21
下一篇:
Java TableRegionModel类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap