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


Java RadioButton.setButtonTintList方法代码示例

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


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

示例1: setTint

import android.widget.RadioButton; //导入方法依赖的package包/类
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) {
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{-android.R.attr.state_enabled},
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            // Rdio button includes own alpha for disabled state
            ColorUtil.stripAlpha(ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light)),
            ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
            color
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable d = createTintedDrawable(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl);
        radioButton.setButtonDrawable(d);
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:19,代码来源:TintHelper.java

示例2: tint

import android.widget.RadioButton; //导入方法依赖的package包/类
/**
 * Tint the radio button
 *
 * @param radioButton the radio button
 * @param color       the color
 */
public static void tint(@NonNull RadioButton radioButton, @ColorInt int color) {
    final int disabledColor = getDisabledColor(radioButton.getContext());
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            getThemeAttrColor(radioButton.getContext(), R.attr.colorControlNormal),
            color,
            disabledColor,
            disabledColor
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material);
        Drawable d = DrawableCompat.wrap(radioDrawable);
        DrawableCompat.setTintList(d, sl);
        radioButton.setButtonDrawable(d);
    }
}
 
开发者ID:jumaallan,项目名称:AndelaTrackChallenge,代码行数:29,代码来源:Easel.java

示例3: setTint

import android.widget.RadioButton; //导入方法依赖的package包/类
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color, boolean useDarker) {
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{-android.R.attr.state_enabled},
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            // Rdio button includes own alpha for disabled state
            ATEUtil.stripAlpha(ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light)),
            ContextCompat.getColor(radioButton.getContext(), useDarker ? R.color.ate_control_normal_dark : R.color.ate_control_normal_light),
            color
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable d = createTintedDrawable(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material), sl);
        radioButton.setButtonDrawable(d);
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:19,代码来源:TintHelper.java

示例4: setRadioButtonDrawable

import android.widget.RadioButton; //导入方法依赖的package包/类
private static void setRadioButtonDrawable(Context context, RadioButton button,
                                           @DrawableRes int id) {
    ColorStateList list = new ColorStateList(new int[][] {
            new int[] { -android.R.attr.state_checked },
            new int[] { android.R.attr.state_checked }
    }, new int[] {
            ThemeUtils.getColor(context, R.attr.compose_image_button_tint),
            ThemeUtils.getColor(context, R.attr.colorAccent)
    });
    Drawable drawable = VectorDrawableCompat.create(context.getResources(), id,
            context.getTheme());
    if (drawable == null) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        button.setButtonTintList(list);
    } else {
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTintList(drawable, list);
    }
    button.setButtonDrawable(drawable);
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:23,代码来源:ComposeOptionsFragment.java

示例5: setTint

import android.widget.RadioButton; //导入方法依赖的package包/类
public static void setTint(@NonNull RadioButton radioButton,
                           @NonNull ColorStateList colors) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(colors);
    } else {
        Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(),
                R.drawable.abc_btn_radio_material);
        Drawable d = DrawableCompat.wrap(radioDrawable);
        DrawableCompat.setTintList(d, colors);
        radioButton.setButtonDrawable(d);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:MDTintHelper.java

示例6: getView

import android.widget.RadioButton; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {
        final ViewGroup nullParent = null;
        convertView = mLayoutInflater.inflate(R.layout.theme_dialog, nullParent);
    }

    String theme = themeOptions[position];

    TextView txtView = convertView.findViewById(R.id.title);
    txtView.setText(theme);

    RadioButton radioButton = convertView.findViewById(R.id.radio);

    int itemColor = ContextCompat.getColor(context, resolveColor(position));

    ColorStateList colorStateList = new ColorStateList(
            new int[][]{
                    new int[]{android.R.attr.state_enabled}, //enabled
                    new int[]{android.R.attr.state_enabled} //disabled

            },
            new int[]{itemColor, itemColor}
    );

    txtView.setShadowLayer(1.5f, -1, 1, itemColor);
    radioButton.setButtonTintList(colorStateList);

    radioButton.setChecked(themeValues[position].equals(selectedTheme));
    return convertView;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:33,代码来源:ThemePreference.java

示例7: themeRadioButton

import android.widget.RadioButton; //导入方法依赖的package包/类
public void themeRadioButton(RadioButton radioButton) {
	if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		radioButton.setButtonTintList(getTintList());
		radioButton.setTextColor(getTextColor());
	}
}
 
开发者ID:HoraApps,项目名称:Liz,代码行数:7,代码来源:ThemeHelper.java

示例8: themeRadioButton

import android.widget.RadioButton; //导入方法依赖的package包/类
public void themeRadioButton(RadioButton radioButton) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    radioButton.setButtonTintList(getTintList());
    radioButton.setTextColor(getTextColor());
  }
}
 
开发者ID:Arjun-sna,项目名称:Android-AudioRecorder-App,代码行数:7,代码来源:ThemeHelper.java


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