本文整理汇总了Java中android.graphics.drawable.ScaleDrawable类的典型用法代码示例。如果您正苦于以下问题:Java ScaleDrawable类的具体用法?Java ScaleDrawable怎么用?Java ScaleDrawable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScaleDrawable类属于android.graphics.drawable包,在下文中一共展示了ScaleDrawable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.tv_transition).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
drawable.startTransition(3000);
}
});
ScaleDrawable scaleDrawable = (ScaleDrawable) findViewById(R.id.v_scale).getBackground();
scaleDrawable.setLevel(10); //lever默认为0,无法显示。level范围为0~10000。level越大,显示的越大
ClipDrawable clipDrawable = (ClipDrawable) findViewById(R.id.v_clip).getBackground();
clipDrawable.setLevel(5000);
View vCustom = findViewById(R.id.v_custom);
CustomDrawable customDrawable = new CustomDrawable(getResources().getColor(R.color.colorAccent));
vCustom.setBackground(customDrawable);
}
开发者ID:DysaniazzZ,项目名称:ArtOfAndroid,代码行数:24,代码来源:MainActivity.java
示例2: assertEquals
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
public static void assertEquals(ScaleDrawable a,ScaleDrawable b)
{
assertEqualsDrawableWrapper(a, b);
assertEquals(a.isStateful(), b.isStateful());
Drawable.ConstantState a_state = a.getConstantState();
Drawable.ConstantState b_state = b.getConstantState();
Class classScaleState = TestUtil.resolveClass(ScaleDrawable.class.getName() + "$ScaleState");
assertEquals((Float) TestUtil.getField(a_state, classScaleState, "mScaleWidth"), (Float) TestUtil.getField(b_state, classScaleState, "mScaleWidth"));
assertEquals((Float) TestUtil.getField(a_state, classScaleState, "mScaleHeight"), (Float) TestUtil.getField(b_state, classScaleState, "mScaleHeight"));
assertEquals((Integer) TestUtil.getField(a_state, classScaleState, "mGravity"), (Integer) TestUtil.getField(b_state, classScaleState, "mGravity"));
// android:drawable
if (Build.VERSION.SDK_INT < TestUtil.MARSHMALLOW) // 23
{
assertEquals((Drawable) TestUtil.getField(a_state, classScaleState, "mDrawable"), (Drawable) TestUtil.getField(b_state, classScaleState, "mDrawable"));
}
}
开发者ID:jmarranz,项目名称:itsnat_droid,代码行数:21,代码来源:Assert.java
示例3: onWindowFocusChanged
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// test transition
View v = findViewById(R.id.test_transition);
TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
drawable.startTransition(1000);
// test scale
View testScale = findViewById(R.id.test_scale);
ScaleDrawable testScaleDrawable = (ScaleDrawable) testScale.getBackground();
testScaleDrawable.setLevel(10);
// test clip
ImageView testClip = (ImageView) findViewById(R.id.test_clip);
ClipDrawable testClipDrawable = (ClipDrawable) testClip.getDrawable();
testClipDrawable.setLevel(8000);
// test custom drawable
View testCustomDrawable = findViewById(R.id.test_custom_drawable);
CustomDrawable customDrawable = new CustomDrawable(Color.parseColor("#0ac39e"));
testCustomDrawable.setBackgroundDrawable(customDrawable);
}
}
开发者ID:singwhatiwanna,项目名称:android-art-res,代码行数:26,代码来源:MainActivity.java
示例4: applyThumbTint
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
/**
* Applies current thumb tint from {@link Decorator#mTintInfo} to the current thumb drawable.
* <p>
* <b>Note</b>, that for post {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} this
* method does nothing.
*/
@SuppressWarnings("ConstantConditions")
private void applyThumbTint() {
this.ensureDecorator();
if (UiConfig.MATERIALIZED || mThumb == null || !mDecorator.hasTintInfo()) {
return;
}
final Drawable thumb = mThumb instanceof ScaleDrawable ? ((ScaleDrawable) mThumb).getDrawable() : mThumb;
final SeekBarTintInfo tintInfo = mDecorator.getTintInfo();
if ((!tintInfo.hasTintList && !tintInfo.hasTintMode)) {
return;
}
final boolean isTintDrawable = thumb instanceof TintDrawable;
final TintDrawable tintDrawable = isTintDrawable ? (TintDrawable) thumb : new TintDrawable(thumb);
if (tintInfo.hasTintList) {
tintDrawable.setTintList(tintInfo.tintList);
}
if (tintInfo.hasTintMode) {
tintDrawable.setTintMode(tintInfo.tintMode);
}
if (tintDrawable.isStateful()) {
tintDrawable.setState(getDrawableState());
}
if (isTintDrawable) {
return;
}
final int thumbOffset = getThumbOffset();
this.mThumb = mDecorator.hasPrivateFlag(PFLAG_DISCRETE) ?
mAnimations.makeThumbScaleable(tintDrawable, Gravity.CENTER) :
tintDrawable;
super.setThumb(mThumb);
tintDrawable.attachCallback();
setThumbOffset(thumbOffset);
}
开发者ID:universum-studios,项目名称:android_ui,代码行数:41,代码来源:SeekBarWidget.java
示例5: setThumbScale
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
/**
* Updates a scale level of the thumb's drawable.
*
* @param scale The scale value from the range {@code [0.0, 1.0]}.
*/
@SuppressWarnings("Range")
void setThumbScale(float scale) {
if (view.mThumb instanceof ScaleDrawable) {
final int scaleLevel = Math.round(scale * MAX_LEVEL);
view.mThumb.setLevel(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN ?
scaleLevel :
// Correct scale level for pre JELLY_BEAN Android versions.
// scaleLevel(10000) = scale(1.0) [expected scale(1.0)]
// scaleLevel(5000) = scale(0.0) [expected scale(0.5)]
// scaleLevel(0) = scale(1.0) [expected scale(0.0)]
scaleLevel + (int) ((10000 - scaleLevel) / 10000f * 5000)
);
}
}
开发者ID:universum-studios,项目名称:android_ui,代码行数:20,代码来源:SeekBarWidget.java
示例6: setupDrawables
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
private void setupDrawables() {
parts = new ArrayList<>();
parts.add(ContextCompat.getDrawable(getContext(), R.drawable.carriage_part1));
parts.add(ContextCompat.getDrawable(getContext(), R.drawable.carriage_part2));
parts.add(ContextCompat.getDrawable(getContext(), R.drawable.carriage_part3));
carriageOffset = (int) getContext().getResources().getDimension(R.dimen.carriage_offset);
pageOffset = (int) getContext().getResources().getDimension(R.dimen.page_offset);
offset = (int) getContext().getResources().getDimension(R.dimen.offset);
button = ContextCompat.getDrawable(getContext(), R.drawable.button);
buttonPressed = ContextCompat.getDrawable(getContext(), R.drawable.button_pressed);
page = new ScaleDrawable(ContextCompat.getDrawable(getContext(), R.drawable.page),
TOP, -1, 1);
page.setLevel(10000);
pageBack =
new ScaleDrawable(ContextCompat.getDrawable(getContext(), R.drawable.page_revers),
TOP, -1, 1);
pageBack.setLevel(0);
keyboard = ContextCompat.getDrawable(getContext(), R.drawable.keyboard_bg);
typewriter = ContextCompat.getDrawable(getContext(), R.drawable.machine);
space = ContextCompat.getDrawable(getContext(), R.drawable.space);
spacePressed = ContextCompat.getDrawable(getContext(), R.drawable.space_pressed);
letter = ContextCompat.getDrawable(getContext(), R.drawable.letter);
}
开发者ID:Ilya-Gh,项目名称:Typewriter,代码行数:28,代码来源:TypewriterRefreshDrawable.java
示例7: canSafelyMutateDrawable
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
/**
* Some drawable implementations have problems with mutation. This method returns false if
* there is a known issue in the given drawable's implementation.
*/
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
return false;
} else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
// GradientDrawable has a bug pre-ICS which results in mutate() resulting
// in loss of color
return false;
} else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
return false;
}
if (drawable instanceof DrawableContainer) {
// If we have a DrawableContainer, let's traverse its child array
final Drawable.ConstantState state = drawable.getConstantState();
if (state instanceof DrawableContainer.DrawableContainerState) {
final DrawableContainer.DrawableContainerState containerState =
(DrawableContainer.DrawableContainerState) state;
for (final Drawable child : containerState.getChildren()) {
if (!canSafelyMutateDrawable(child)) {
return false;
}
}
}
} else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
return canSafelyMutateDrawable(
((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
.getWrappedDrawable());
} /*else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
return canSafelyMutateDrawable(
((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
.getWrappedDrawable());
}*/ else if (drawable instanceof ScaleDrawable) {
return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
}
return true;
}
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:42,代码来源:DrawableUtils.java
示例8: setEventsIcon
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
public void setEventsIcon(@DrawableRes int drawableRes) {
Drawable drawable = ContextCompat.getDrawable(getContext(), drawableRes);
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
drawable.setBounds(0, 0, width / 2, height / 2);
ScaleDrawable sd = new ScaleDrawable(drawable, Gravity.CENTER, 0.6f, 0.6f);
sd.setLevel(8000);
ViewHelper.tintDrawable(drawable, ViewHelper.getTertiaryTextColor(getContext()));
setCompoundDrawablesWithIntrinsicBounds(sd, null, null, null);
}
开发者ID:duyp,项目名称:mvvm-template,代码行数:11,代码来源:FontTextView.java
示例9: setSeekBarBg
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
private void setSeekBarBg(){
try {
int progressColor = CustomAttrValueUtil.getAttrColorValue(R.attr.colorPrimary,R.color.colorAccent,this);
LayerDrawable layerDrawable = (LayerDrawable) seekBar.getProgressDrawable();
ScaleDrawable scaleDrawable = (ScaleDrawable)layerDrawable.findDrawableByLayerId(android.R.id.progress);
GradientDrawable drawable = (GradientDrawable) scaleDrawable.getDrawable();
drawable.setColor(progressColor);
}catch (Exception e){
e.printStackTrace();
}
}
开发者ID:lijunyandev,项目名称:MeetMusic,代码行数:12,代码来源:PlayActivity.java
示例10: canSafelyMutateDrawable
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
/**
* Some drawable implementations have problems with mutation. This method returns false if
* there is a known issue in the given drawable's implementation.
*/
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
return false;
} else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
// GradientDrawable has a bug pre-ICS which results in mutate() resulting
// in loss of color
return false;
} else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
return false;
}
if (drawable instanceof DrawableContainer) {
// If we have a DrawableContainer, let's traverse it's child array
final Drawable.ConstantState state = drawable.getConstantState();
if (state instanceof DrawableContainer.DrawableContainerState) {
final DrawableContainer.DrawableContainerState containerState =
(DrawableContainer.DrawableContainerState) state;
for (final Drawable child : containerState.getChildren()) {
if (!canSafelyMutateDrawable(child)) {
return false;
}
}
}
} else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
return canSafelyMutateDrawable(
((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
.getWrappedDrawable());
} else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
return canSafelyMutateDrawable(
((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
.getWrappedDrawable());
} else if (drawable instanceof ScaleDrawable) {
return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
}
return true;
}
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:42,代码来源:SkinCompatDrawableUtils.java
示例11: m2634b
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
public static boolean m2634b(Drawable drawable) {
if (drawable instanceof LayerDrawable) {
return VERSION.SDK_INT >= 16;
} else if (drawable instanceof InsetDrawable) {
return VERSION.SDK_INT >= 14;
} else {
if (drawable instanceof StateListDrawable) {
return VERSION.SDK_INT >= 8;
} else {
if (drawable instanceof GradientDrawable) {
return VERSION.SDK_INT >= 14;
} else {
if (!(drawable instanceof DrawableContainer)) {
return drawable instanceof C0063q ? m2634b(((C0063q) drawable).m469a()) : drawable instanceof C0244a ? m2634b(((C0244a) drawable).m1984a()) : drawable instanceof ScaleDrawable ? m2634b(((ScaleDrawable) drawable).getDrawable()) : true;
} else {
ConstantState constantState = drawable.getConstantState();
if (!(constantState instanceof DrawableContainerState)) {
return true;
}
for (Drawable b : ((DrawableContainerState) constantState).getChildren()) {
if (!m2634b(b)) {
return false;
}
}
return true;
}
}
}
}
}
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:31,代码来源:bt.java
示例12: setupProgressColor
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
/***
* Method called from APIs below 21 to setup Progress Color
*/
private void setupProgressColor() {
//load up the drawable and apply color
LayerDrawable ld = (LayerDrawable) getProgressDrawable();
ScaleDrawable shape = (ScaleDrawable) (ld.findDrawableByLayerId(android.R.id.progress));
shape.setColorFilter(mProgressColor, PorterDuff.Mode.SRC_IN);
//set the background to transparent
NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) (ld.findDrawableByLayerId(android.R.id.background));
ninePatchDrawable.setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
}
开发者ID:goodev,项目名称:droidddle,代码行数:14,代码来源:SeekBarCompat.java
示例13: setEnabled
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
@Override
public void setEnabled(final boolean enabled) {
mIsEnabled = enabled;
triggerMethodOnceViewIsDisplayed(this, new Callable<Void>() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public Void call() throws Exception {
if (!lollipopAndAbove()) {
gradientDrawable = new GradientDrawable();
gradientDrawable.setShape(GradientDrawable.OVAL);
gradientDrawable.setSize(mOriginalThumbHeight / 3, mOriginalThumbHeight / 3);
gradientDrawable.setColor(mIsEnabled ? mThumbColor : Color.LTGRAY);
gradientDrawable.setDither(true);
gradientDrawable.setAlpha(mThumbAlpha);
setThumb(gradientDrawable);
//load up the drawable and apply color
LayerDrawable ld = (LayerDrawable) getProgressDrawable();
ScaleDrawable shape = (ScaleDrawable) (ld.findDrawableByLayerId(android.R.id.progress));
shape.setColorFilter(mIsEnabled ? mProgressColor : Color.LTGRAY, PorterDuff.Mode.SRC_IN);
//set the background to transparent
NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) (ld.findDrawableByLayerId(android.R.id.background));
ninePatchDrawable.setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
//background
//load up the drawable and apply color
SeekBarBackgroundDrawable seekBarBackgroundDrawable = new SeekBarBackgroundDrawable(getContext(),
mIsEnabled ? mProgressBackgroundColor : Color.LTGRAY, mActualBackgroundColor, getPaddingLeft(), getPaddingRight());
if (belowJellybean())
setBackgroundDrawable(seekBarBackgroundDrawable);
else
setBackground(seekBarBackgroundDrawable);
}
SeekBarCompat.super.setEnabled(enabled);
return null;
}
});
}
开发者ID:goodev,项目名称:droidddle,代码行数:38,代码来源:SeekBarCompat.java
示例14: setupProgressColor
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
/***
* Method called from APIs below 21 to setup Progress Color
*/
private void setupProgressColor() {
try {
//load up the drawable and apply color
LayerDrawable ld = (LayerDrawable) getProgressDrawable();
ScaleDrawable shape = (ScaleDrawable) (ld.findDrawableByLayerId(android.R.id.progress));
shape.setColorFilter(mProgressColor, PorterDuff.Mode.SRC_IN);
//set the background to transparent
NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) (ld.findDrawableByLayerId(android.R.id.background));
ninePatchDrawable.setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
} catch (NullPointerException e) {
//TODO: Handle exception
}
}
开发者ID:Minitour,项目名称:crofis-android-uikit,代码行数:18,代码来源:SeekBarCompat.java
示例15: setEnabled
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
/***
* Enables or disables the whole seekBar!
*
* @param enabled
*/
@Override
public void setEnabled(final boolean enabled) {
mIsEnabled = enabled;
triggerMethodOnceViewIsDisplayed(this, new Callable<Void>() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public Void call() throws Exception {
if (!lollipopAndAbove()) {
gradientDrawable = new GradientDrawable();
gradientDrawable.setShape(GradientDrawable.OVAL);
gradientDrawable.setSize(mOriginalThumbHeight / 3, mOriginalThumbHeight / 3);
gradientDrawable.setColor(mIsEnabled ? mThumbColor : Color.LTGRAY);
gradientDrawable.setDither(true);
gradientDrawable.setAlpha(mThumbAlpha);
setThumb(gradientDrawable);
//load up the drawable and apply color
LayerDrawable ld = (LayerDrawable) getProgressDrawable();
ScaleDrawable shape = (ScaleDrawable) (ld.findDrawableByLayerId(android.R.id.progress));
shape.setColorFilter(mIsEnabled ? mProgressColor : Color.LTGRAY, PorterDuff.Mode.SRC_IN);
//set the background to transparent
NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) (ld.findDrawableByLayerId(android.R.id.background));
ninePatchDrawable.setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
//background
//load up the drawable and apply color
SeekBarBackgroundDrawable seekBarBackgroundDrawable = new SeekBarBackgroundDrawable(getContext(),
mIsEnabled ? mProgressBackgroundColor : Color.LTGRAY, mActualBackgroundColor, getPaddingLeft(), getPaddingRight());
if (belowJellybean())
setBackgroundDrawable(seekBarBackgroundDrawable);
else
setBackground(seekBarBackgroundDrawable);
}
SeekBarCompat.super.setEnabled(enabled);
return null;
}
});
}
开发者ID:Minitour,项目名称:crofis-android-uikit,代码行数:43,代码来源:SeekBarCompat.java
示例16: isAttributeIgnored
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
@Override
public boolean isAttributeIgnored(ScaleDrawable resource, String namespaceURI, String name)
{
if (super.isAttributeIgnored(resource,namespaceURI,name))
return true;
if (NamespaceUtil.XMLNS_ANDROID.equals(namespaceURI))
{
// Se usan en tiempo de construcción
return ("drawable".equals(name) || "scaleGravity".equals(name) || "scaleHeight".equals(name) || "scaleWidth".equals(name));
}
return false;
}
开发者ID:jmarranz,项目名称:itsnat_droid,代码行数:14,代码来源:ClassDescScaleDrawable.java
示例17: tileifyProgressDrawable
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
private Drawable tileifyProgressDrawable(Drawable wrapped) {
if (wrapped instanceof LayerDrawable) {
LayerDrawable drawable = (LayerDrawable) wrapped;
final int N = drawable.getNumberOfLayers();
Drawable[] outDrawables = new Drawable[N];
for (int i = 0; i < N; i++) {
final int id = drawable.getId(i);
Drawable childDrawable = drawable.getDrawable(i);
if (id == android.R.id.background) {
outDrawables[i] = new NumberBGDrawable(childDrawable);
} else if (id == android.R.id.progress) {
if (childDrawable instanceof ScaleDrawable) {
outDrawables[i] = tileifyScaleDrawable((ScaleDrawable) childDrawable);
} else if (childDrawable instanceof ClipDrawable) {
outDrawables[i] = tileifyClipDrawable((ClipDrawable) childDrawable);
} else {
outDrawables[i] = childDrawable;
}
} else {
outDrawables[i] = childDrawable;
}
}
LayerDrawable newDrawable = new NumberLayerDrawable(outDrawables);
return newDrawable;
}
return wrapped;
}
开发者ID:v7lin,项目名称:Android_Skin_2.0,代码行数:28,代码来源:NumberProgressBar.java
示例18: applyDiscreteIndicatorTint
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
/**
* Applies current discrete indicator tint from {@link Decorator#mTintInfo} to the current discrete
* indicator's drawable.
*/
@SuppressLint("NewApi")
@SuppressWarnings("ConstantConditions")
private void applyDiscreteIndicatorTint() {
this.ensureDecorator();
if (mDiscreteIndicator == null || !mDecorator.hasTintInfo()) {
return;
}
final Drawable indicator = mDiscreteIndicator instanceof ScaleDrawable ? ((ScaleDrawable) mDiscreteIndicator).getDrawable() : mDiscreteIndicator;
final SeekBarTintInfo tintInfo = mDecorator.getTintInfo();
if ((!tintInfo.hasDiscreteIndicatorTintList && !tintInfo.hasDiscreteIndicatorTintMode)) {
return;
}
if (UiConfig.MATERIALIZED) {
this.mDiscreteIndicator = mDiscreteIndicator.mutate();
if (tintInfo.hasDiscreteIndicatorTintList) {
mDiscreteIndicator.setTintList(tintInfo.discreteIndicatorTintList);
}
if (tintInfo.hasDiscreteIndicatorTintMode) {
mDiscreteIndicator.setTintMode(tintInfo.discreteIndicatorTintMode);
}
if (mDiscreteIndicator.isStateful()) {
mDiscreteIndicator.setState(getDrawableState());
}
return;
}
final boolean isTintDrawable = indicator instanceof TintDrawable;
final TintDrawable tintDrawable = isTintDrawable ? (TintDrawable) indicator : new TintDrawable(indicator);
if (tintInfo.hasDiscreteIndicatorTintList) {
tintDrawable.setTintList(tintInfo.discreteIndicatorTintList);
}
if (tintInfo.hasDiscreteIndicatorTintMode) {
tintDrawable.setTintMode(tintInfo.discreteIndicatorTintMode);
}
if (isTintDrawable) {
return;
}
this.mDiscreteIndicator = mDecorator.hasPrivateFlag(PFLAG_DISCRETE) ?
mAnimations.makeDiscreteIndicatorScaleable(tintDrawable, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL) :
tintDrawable;
mDiscreteIndicator.setCallback(this);
updateDiscreteIndicatorState(getDrawableState(), false);
}
开发者ID:universum-studios,项目名称:android_ui,代码行数:47,代码来源:SeekBarWidget.java
示例19: clickBarOn
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
private void clickBarOn(FrameLayout frameLayout) {
pins.get((int) frameLayout.getTag()).setVisibility(View.VISIBLE);
isOldBarClicked = true;
int childCount = frameLayout.getChildCount();
for (int i = 0; i < childCount; i++) {
View childView = frameLayout.getChildAt(i);
if (childView instanceof LinearLayout) {
LinearLayout linearLayout = (LinearLayout) childView;
Bar bar = (Bar) linearLayout.getChildAt(0);
TextView titleTxtView = (TextView) linearLayout.getChildAt(1);
LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
layerDrawable.mutate();
ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);
GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();
if (mPinBackgroundColor != 0) {
if (progressLayer != null) {
progressLayer.setColor(ContextCompat.getColor(mContext, mProgressClickColor));
}
} else {
if (progressLayer != null) {
progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.holo_green_dark));
}
}
if (mBarTitleSelectedColor > 0) {
titleTxtView.setTextColor(ContextCompat.getColor(mContext, mBarTitleSelectedColor));
} else {
titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.holo_green_dark));
}
}
}
}
开发者ID:hadiidbouk,项目名称:ChartProgressBar-Android,代码行数:44,代码来源:ChartProgressBar.java
示例20: disableBar
import android.graphics.drawable.ScaleDrawable; //导入依赖的package包/类
public void disableBar(int index) {
final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();
for (int i = 0; i < barsCount; i++) {
FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);
int rootChildCount = rootFrame.getChildCount();
for (int j = 0; j < rootChildCount; j++) {
if ((int) rootFrame.getTag() != index)
continue;
rootFrame.setEnabled(false);
rootFrame.setClickable(false);
View childView = rootFrame.getChildAt(j);
if (childView instanceof LinearLayout) {
//bar
LinearLayout barContainerLinear = ((LinearLayout) childView);
int barContainerCount = barContainerLinear.getChildCount();
for (int k = 0; k < barContainerCount; k++) {
View view = barContainerLinear.getChildAt(k);
if (view instanceof Bar) {
Bar bar = (Bar) view;
LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
layerDrawable.mutate();
ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);
GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();
if (progressLayer != null) {
if (mProgressDisableColor > 0)
progressLayer.setColor(ContextCompat.getColor(mContext, mProgressDisableColor));
else
progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
}
} else {
TextView titleTxtView = (TextView) view;
if (mProgressDisableColor > 0)
titleTxtView.setTextColor(ContextCompat.getColor(mContext, mProgressDisableColor));
else
titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
}
}
}
}
}
}
开发者ID:hadiidbouk,项目名称:ChartProgressBar-Android,代码行数:59,代码来源:ChartProgressBar.java
注:本文中的android.graphics.drawable.ScaleDrawable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论