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


Java CompoundButtonCompat.getButtonDrawable方法代码示例

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


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

示例1: 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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:AppCompatCompoundButtonHelper.java

示例2: 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;
}
 
开发者ID:Bilibili,项目名称:MagicaSakura,代码行数:22,代码来源:AppCompatCompoundButtonHelper.java

示例3: 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);
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:19,代码来源:AppCompatCompoundButtonHelper.java

示例4: 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);
    }
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:22,代码来源:AppCompatCompoundButtonHelper.java

示例5: 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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:AppCompatCompoundButtonHelper.java

示例6: 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();
        }
    }
}
 
开发者ID:Bilibili,项目名称:MagicaSakura,代码行数:15,代码来源:TintRadioButton.java

示例7: 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;
}
 
开发者ID:Bilibili,项目名称:MagicaSakura,代码行数:12,代码来源:AppCompatCompoundButtonHelper.java

示例8: 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;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:12,代码来源:AppCompatCompoundButtonHelper.java

示例9: getCompoundPaddingLeft

import android.support.v4.widget.CompoundButtonCompat; //导入方法依赖的package包/类
int getCompoundPaddingLeft(int i)
{
    int j = i;
    if (android.os.Build.VERSION.SDK_INT < 17)
    {
        Drawable drawable = CompoundButtonCompat.getButtonDrawable(mView);
        j = i;
        if (drawable != null)
        {
            j = i + drawable.getIntrinsicWidth();
        }
    }
    return j;
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:15,代码来源:AppCompatCompoundButtonHelper.java

示例10: onDraw

import android.support.v4.widget.CompoundButtonCompat; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
	// If there's text of any sort resort to CompoundButton#onDraw
	if (getText() != null && getText().length() > 0 ||
		getTextOff() != null && getTextOff().length() > 0 ||
		getTextOff() != null && getTextOn().length() > 0) {
		super.onDraw(canvas);
	}
	// Otherwise override CompoundButton#onDraw entirely to allow properly aligned image toggles
	else {
		final Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(this);
		if (buttonDrawable != null) {
			final int verticalGravity = getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
			final int horizontalGravity = getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK;
			final int drawableHeight = buttonDrawable.getIntrinsicHeight();
			final int drawableWidth = buttonDrawable.getIntrinsicWidth();

			final int top;
			switch (verticalGravity) {
				case Gravity.BOTTOM:
					top = getHeight() - drawableHeight;
					break;
				case Gravity.CENTER_VERTICAL:
					top = (getHeight() - drawableHeight) / 2;
					break;
				default:
					top = 0;
			}

			final int left;
			switch (horizontalGravity) {
				case Gravity.RIGHT:
				case Gravity.END:
					left = getWidth() - drawableWidth;
					break;
				case Gravity.CENTER_HORIZONTAL:
					left = (getWidth() - drawableWidth) / 2;
					break;
				default:
					left = 0;
			}

			final int bottom = top + drawableHeight;
			final int right = left + drawableWidth;

			buttonDrawable.setBounds(left, top, right, bottom);

			final Drawable background = getBackground();
			if (Build.VERSION.SDK_INT > 21 && background != null) {
				background.setHotspotBounds(left, top, right, bottom);
			}

			buttonDrawable.draw(canvas);
		}
	}
}
 
开发者ID:rcketscientist,项目名称:ToggleButtons,代码行数:57,代码来源:ToggleButton.java


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