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


Java ViewCompat.setBackgroundTintList方法代码示例

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


在下文中一共展示了ViewCompat.setBackgroundTintList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setEditTextDisabled

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private static void setEditTextDisabled(EditText editText) {
    editText.setInputType(InputType.TYPE_NULL);
    editText.setTextIsSelectable(true);
    editText.setKeyListener(null);

    editText.setBackgroundResource(R.drawable.edit_text_readonly);
    int color = StyledAttributesHelper.getColor(editText.getContext(), android.R.attr.textColorSecondary, 0);
    ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(color));
    ((ViewGroup) editText.getParent()).setAddStatesFromChildren(false);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:11,代码来源:EditCommandAliasActivity.java

示例2: setBackgroundActiveColor

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public static void setBackgroundActiveColor(View editText, int accentColor) {
    if (editText.getBackground() == null)
        return;
    int normalColor = StyledAttributesHelper.getColor(editText.getContext(),
            R.attr.colorControlNormal, 0);
    int disabledColor = ColorUtils.setAlphaComponent(normalColor, (int) (255.f *
            StyledAttributesHelper.getFloat(editText.getContext(), android.R.attr.disabledAlpha, 1.f)));
    int[][] states = new int[][]{
            new int[]{-android.R.attr.state_enabled},
            new int[]{-android.R.attr.state_pressed, -android.R.attr.state_focused},
            new int[]{}
    };
    int[] colors = new int[]{
            disabledColor,
            normalColor,
            accentColor
    };
    ColorStateList list = new ColorStateList(states, colors);
    editText.setBackground(new ColorFilterWorkaroundDrawable(editText.getBackground()));
    ViewCompat.setBackgroundTintList(editText, list);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:22,代码来源:ThemedEditText.java

示例3: loadFromAttributes

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
    TypedArray a = this.mView.getContext().obtainStyledAttributes(attrs, R.styleable.ViewBackgroundHelper, defStyleAttr, 0);
    try {
        if (a.hasValue(R.styleable.ViewBackgroundHelper_android_background)) {
            ColorStateList tint = this.mDrawableManager.getTintList(this.mView.getContext(), a.getResourceId(R.styleable.ViewBackgroundHelper_android_background, -1));
            if (tint != null) {
                setInternalBackgroundTint(tint);
            }
        }
        if (a.hasValue(R.styleable.ViewBackgroundHelper_backgroundTint)) {
            ViewCompat.setBackgroundTintList(this.mView, a.getColorStateList(R.styleable.ViewBackgroundHelper_backgroundTint));
        }
        if (a.hasValue(R.styleable.ViewBackgroundHelper_backgroundTintMode)) {
            ViewCompat.setBackgroundTintMode(this.mView, DrawableUtils.parseTintMode(a.getInt(R.styleable.ViewBackgroundHelper_backgroundTintMode, -1), null));
        }
        a.recycle();
    } catch (Throwable th) {
        a.recycle();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:AppCompatBackgroundHelper.java

示例4: setTint

import android.support.v4.view.ViewCompat; //导入方法依赖的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

示例5: setFilterButtonState

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void setFilterButtonState(boolean unread_state, boolean short_state, boolean long_state) {
    ViewCompat.setBackgroundTintList(findViewById(R.id.button_filter_unread),
            ContextCompat.getColorStateList(this,
                    unread_state ? R.color.colorFilterButtonOn : R.color.colorFilterButtonOff));
    ViewCompat.setBackgroundTintList(findViewById(R.id.button_filter_short),
            ContextCompat.getColorStateList(this,
                    short_state ? R.color.colorFilterButtonOn : R.color.colorFilterButtonOff));
    ViewCompat.setBackgroundTintList(findViewById(R.id.button_filter_long),
            ContextCompat.getColorStateList(this,
                    long_state ? R.color.colorFilterButtonOn : R.color.colorFilterButtonOff));
}
 
开发者ID:PaulKlinger,项目名称:Sprog-App,代码行数:12,代码来源:MainActivity.java

示例6: render

import android.support.v4.view.ViewCompat; //导入方法依赖的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

示例7: setupBackground

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public static void setupBackground(View view, AttributeSet attrs) {
    StyledAttributesHelper r = StyledAttributesHelper.obtainStyledAttributes(view.getContext(), attrs, ATTRS_BG);
    int bgResId = r.getResourceId(android.R.attr.background, 0);
    if (bgResId == R.color.colorPrimary)
        view.setBackgroundColor(ThemeHelper.getPrimaryColor(view.getContext()));
    else if (bgResId == R.color.colorAccent)
        view.setBackgroundColor(ThemeHelper.getAccentColor(view.getContext()));
    else if (bgResId == R.drawable.colored_button)
        ViewCompat.setBackgroundTintList(view, createColoredButtonColorStateList(view.getContext()));
    r.recycle();
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:12,代码来源:ThemedView.java

示例8: tint

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * Tint the button
 *
 * @param button the button
 * @param color  the color
 */
public static void tint(@NonNull Button button, @ColorInt int color) {
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{}
    }, new int[]{
            color
    });
    ViewCompat.setBackgroundTintList(button, sl);
}
 
开发者ID:jumaallan,项目名称:AndelaTrackChallenge,代码行数:15,代码来源:Easel.java

示例9: onCreate

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    setDrawUnderStatusbar(true);
    super.onCreate(savedInstanceState);
    ButterKnife.bind(this);

    mDisposable = new CompositeDisposable();

    setBottomBarVisibility(View.GONE);

    ViewUtil.setStatusBarHeight(this, statusBar);


    mGenre = getIntent().getExtras().getParcelable(EXTRA_GENRE_ID);
    mPresenter = new GenreDetailsPresenter(Injection.provideRepository(this),
            this,
            mGenre.id);


    setUpToolBar();
    setupRecyclerView();


    int themeColor = ThemeStore.accentColor(this);
    ViewCompat.setBackgroundTintList(playSongs, ColorStateList.valueOf(themeColor));
    shuffleSongs.setTextColor(themeColor);
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:28,代码来源:GenreDetailsActivity.java


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