本文整理汇总了Java中android.support.v4.widget.CompoundButtonCompat类的典型用法代码示例。如果您正苦于以下问题:Java CompoundButtonCompat类的具体用法?Java CompoundButtonCompat怎么用?Java CompoundButtonCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompoundButtonCompat类属于android.support.v4.widget包,在下文中一共展示了CompoundButtonCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadFromAttributes
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
TypedArray a = this.mView.getContext().obtainStyledAttributes(attrs, R.styleable.CompoundButton, defStyleAttr, 0);
try {
if (a.hasValue(R.styleable.CompoundButton_android_button)) {
int resourceId = a.getResourceId(R.styleable.CompoundButton_android_button, 0);
if (resourceId != 0) {
this.mView.setButtonDrawable(this.mDrawableManager.getDrawable(this.mView.getContext(), resourceId));
}
}
if (a.hasValue(R.styleable.CompoundButton_buttonTint)) {
CompoundButtonCompat.setButtonTintList(this.mView, a.getColorStateList(R.styleable.CompoundButton_buttonTint));
}
if (a.hasValue(R.styleable.CompoundButton_buttonTintMode)) {
CompoundButtonCompat.setButtonTintMode(this.mView, DrawableUtils.parseTintMode(a.getInt(R.styleable.CompoundButton_buttonTintMode, -1), null));
}
a.recycle();
} catch (Throwable th) {
a.recycle();
}
}
示例2: applyButtonTint
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
void applyButtonTint() {
Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(this.mView);
if (buttonDrawable == null) {
return;
}
if (this.mHasButtonTint || this.mHasButtonTintMode) {
buttonDrawable = DrawableCompat.wrap(buttonDrawable).mutate();
if (this.mHasButtonTint) {
DrawableCompat.setTintList(buttonDrawable, this.mButtonTintList);
}
if (this.mHasButtonTintMode) {
DrawableCompat.setTintMode(buttonDrawable, this.mButtonTintMode);
}
if (buttonDrawable.isStateful()) {
buttonDrawable.setState(this.mView.getDrawableState());
}
this.mView.setButtonDrawable(buttonDrawable);
}
}
示例3: applySupportButtonDrawableTint
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
public boolean applySupportButtonDrawableTint() {
Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(mView);
if (buttonDrawable != null && mCompoundButtonTintInfo != null && mCompoundButtonTintInfo.mHasTintList) {
buttonDrawable = DrawableCompat.wrap(buttonDrawable);
buttonDrawable = buttonDrawable.mutate();
if (mCompoundButtonTintInfo.mHasTintList) {
DrawableCompat.setTintList(buttonDrawable, mCompoundButtonTintInfo.mTintList);
}
if (mCompoundButtonTintInfo.mHasTintMode) {
DrawableCompat.setTintMode(buttonDrawable, mCompoundButtonTintInfo.mTintMode);
}
// The drawable (or one of its children) may not have been
// stateful before applying the tint, so let's try again.
if (buttonDrawable.isStateful()) {
buttonDrawable.setState(mView.getDrawableState());
}
setButtonDrawable(buttonDrawable);
return true;
}
return false;
}
示例4: applyButtonTint
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
private void applyButtonTint()
{
Drawable localDrawable1 = CompoundButtonCompat.getButtonDrawable(this.mView);
if ((localDrawable1 != null) && ((this.mHasButtonTint) || (this.mHasButtonTintMode)))
{
Drawable localDrawable2 = DrawableCompat.wrap(localDrawable1).mutate();
if (this.mHasButtonTint) {
DrawableCompat.setTintList(localDrawable2, this.mButtonTintList);
}
if (this.mHasButtonTintMode) {
DrawableCompat.setTintMode(localDrawable2, this.mButtonTintMode);
}
if (localDrawable2.isStateful()) {
localDrawable2.setState(this.mView.getDrawableState());
}
this.mView.setButtonDrawable(localDrawable2);
}
}
示例5: loadFromAttributes
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
final void loadFromAttributes(AttributeSet paramAttributeSet, int paramInt)
{
TypedArray localTypedArray = this.mView.getContext().obtainStyledAttributes(paramAttributeSet, R.styleable.CompoundButton, paramInt, 0);
try
{
if (localTypedArray.hasValue(R.styleable.CompoundButton_android_button))
{
int i = localTypedArray.getResourceId(R.styleable.CompoundButton_android_button, 0);
if (i != 0) {
this.mView.setButtonDrawable(this.mTintManager.getDrawable(i, false));
}
}
if (localTypedArray.hasValue(R.styleable.CompoundButton_buttonTint)) {
CompoundButtonCompat.setButtonTintList(this.mView, localTypedArray.getColorStateList(R.styleable.CompoundButton_buttonTint));
}
if (localTypedArray.hasValue(R.styleable.CompoundButton_buttonTintMode)) {
CompoundButtonCompat.setButtonTintMode(this.mView, DrawableUtils.parseTintMode$49602678(localTypedArray.getInt(R.styleable.CompoundButton_buttonTintMode, -1)));
}
return;
}
finally
{
localTypedArray.recycle();
}
}
示例6: applyButtonTint
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
void applyButtonTint()
{
Drawable drawable = CompoundButtonCompat.getButtonDrawable(mView);
if (drawable != null && (mHasButtonTint || mHasButtonTintMode))
{
drawable = DrawableCompat.wrap(drawable).mutate();
if (mHasButtonTint)
{
DrawableCompat.setTintList(drawable, mButtonTintList);
}
if (mHasButtonTintMode)
{
DrawableCompat.setTintMode(drawable, mButtonTintMode);
}
if (drawable.isStateful())
{
drawable.setState(mView.getDrawableState());
}
mView.setButtonDrawable(drawable);
}
}
示例7: setTheme
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
@Override
public void setTheme() {
super.setTheme();
int checkTint = ThemeUtils.resolveColor(getContext(), R.attr.gallery_checkbox_button_tint_color, R.color.gallery_default_checkbox_button_tint_color);
CompoundButtonCompat.setButtonTintList(mCbCheck, ColorStateList.valueOf(checkTint));
int cbTextColor = ThemeUtils.resolveColor(getContext(), R.attr.gallery_checkbox_text_color, R.color.gallery_default_checkbox_text_color);
mCbCheck.setTextColor(cbTextColor);
int pageColor = ThemeUtils.resolveColor(getContext(), R.attr.gallery_page_bg, R.color.gallery_default_page_bg);
mRlRootView.setBackgroundColor(pageColor);
}
示例8: BucketViewHolder
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
BucketViewHolder(ViewGroup parent, View itemView) {
super(itemView);
this.mParentView = parent;
mTvBucketName = (TextView) itemView.findViewById(R.id.tv_bucket_name);
mIvBucketCover = (SquareImageView) itemView.findViewById(R.id.iv_bucket_cover);
mRbSelected = (AppCompatRadioButton) itemView.findViewById(R.id.rb_selected);
itemView.setOnClickListener(this);
int checkTint = ThemeUtils.resolveColor(itemView.getContext(), R.attr.gallery_checkbox_button_tint_color, R.color.gallery_default_checkbox_button_tint_color);
CompoundButtonCompat.setButtonTintList(mRbSelected, ColorStateList.valueOf(checkTint));
}
示例9: GridViewHolder
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
GridViewHolder(View itemView) {
super(itemView);
mIvMediaImage = itemView.findViewById(R.id.iv_media_image);
mCbCheck = (AppCompatCheckBox) itemView.findViewById(R.id.cb_check);
relativeLayout = (SquareRelativeLayout) itemView.findViewById(R.id.rootView);
mLlCamera = (LinearLayout) itemView.findViewById(R.id.ll_camera);
mTvCameraTxt = (TextView) itemView.findViewById(R.id.tv_camera_txt);
mIvCameraImage = (ImageView) itemView.findViewById(R.id.iv_camera_image);
int checkTint = ThemeUtils.resolveColor(itemView.getContext(), R.attr.gallery_checkbox_button_tint_color, R.color.gallery_default_checkbox_button_tint_color);
CompoundButtonCompat.setButtonTintList(mCbCheck, ColorStateList.valueOf(checkTint));
}
示例10: install
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
public static void install(CompoundButton checkBox, AttributeSet attrs) {
ThemedView.setupBackground(checkBox, attrs);
if (ThemeHelper.hasCustomAccentColor(checkBox.getContext())) {
CompoundButtonCompat.setButtonTintList(checkBox,
createCheckBoxTintStateList(checkBox.getContext()));
if (Build.VERSION.SDK_INT >= 21 && checkBox.getBackground() instanceof RippleDrawable) {
((RippleDrawable) checkBox.getBackground()).setColor(
createCheckBoxRippleTintStateList(checkBox.getContext()));
}
}
}
示例11: getCompoundPaddingLeft
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
int getCompoundPaddingLeft(int superValue) {
if (VERSION.SDK_INT >= 17) {
return superValue;
}
Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(this.mView);
if (buttonDrawable != null) {
return superValue + buttonDrawable.getIntrinsicWidth();
}
return superValue;
}
示例12: applySkin
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
@Override
public void applySkin() {
mButtonResourceId = SkinCompatHelper.checkResourceId(mButtonResourceId);
if (mButtonResourceId != INVALID_ID) {
mView.setButtonDrawable(SkinCompatResources.getDrawableCompat(mView.getContext(), mButtonResourceId));
}
mButtonTintResId = SkinCompatHelper.checkResourceId(mButtonTintResId);
if (mButtonTintResId != INVALID_ID) {
CompoundButtonCompat.setButtonTintList(mView, SkinCompatResources.getColorStateList(mView.getContext(), mButtonTintResId));
}
}
示例13: drawableStateChanged
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
if (ThemeUtils.isSkipAnimatedSelector()) {
Drawable drawable = CompoundButtonCompat.getButtonDrawable(this);
try {
if (ThemeUtils.getWrapperDrawable(drawable) instanceof AnimatedStateListDrawable) {
drawable.jumpToCurrentState();
}
} catch (NoClassDefFoundError error) {
error.printStackTrace();
}
}
}
示例14: getCompoundPaddingLeft
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
public int getCompoundPaddingLeft(int superValue) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
// Before JB-MR1 the button drawable wasn't taken into account for padding. We'll
// workaround that here
Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(mView);
if (buttonDrawable != null) {
superValue += buttonDrawable.getIntrinsicWidth();
}
}
return superValue;
}
示例15: getCompoundPaddingLeft
import android.support.v4.widget.CompoundButtonCompat; //导入依赖的package包/类
final int getCompoundPaddingLeft(int paramInt)
{
if (Build.VERSION.SDK_INT < 17)
{
Drawable localDrawable = CompoundButtonCompat.getButtonDrawable(this.mView);
if (localDrawable != null) {
paramInt += localDrawable.getIntrinsicWidth();
}
}
return paramInt;
}