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


Java DrawableCompat类代码示例

本文整理汇总了Java中android.support.v4.graphics.drawable.DrawableCompat的典型用法代码示例。如果您正苦于以下问题:Java DrawableCompat类的具体用法?Java DrawableCompat怎么用?Java DrawableCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DrawableCompat类属于android.support.v4.graphics.drawable包,在下文中一共展示了DrawableCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setStatusBarBackground

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
public void setStatusBarBackground(@Nullable Drawable bg) {
    Drawable drawable = null;
    if (this.mStatusBarBackground != bg) {
        if (this.mStatusBarBackground != null) {
            this.mStatusBarBackground.setCallback(null);
        }
        if (bg != null) {
            drawable = bg.mutate();
        }
        this.mStatusBarBackground = drawable;
        if (this.mStatusBarBackground != null) {
            if (this.mStatusBarBackground.isStateful()) {
                this.mStatusBarBackground.setState(getDrawableState());
            }
            DrawableCompat.setLayoutDirection(this.mStatusBarBackground, ViewCompat.getLayoutDirection(this));
            this.mStatusBarBackground.setVisible(getVisibility() == 0, false);
            this.mStatusBarBackground.setCallback(this);
        }
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:CoordinatorLayout.java

示例2: onCreate

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    marqueeView1 = (SimpleMarqueeView) findViewById(R.id.marqueeView1);
    marqueeView2 = (SimpleMarqueeView) findViewById(R.id.marqueeView2);
    marqueeView3 = (SimpleMarqueeView) findViewById(R.id.marqueeView3);
    yellowSpeaker = (ImageView) findViewById(R.id.yellowSpeaker);
    marqueeView4 = (MarqueeView) findViewById(R.id.marqueeView4);
    marqueeView5 = (SimpleMarqueeView) findViewById(R.id.marqueeView5);
    marqueeView6 = (SimpleMarqueeView) findViewById(R.id.marqueeView6);
    DrawableCompat.setTint(DrawableCompat.wrap(yellowSpeaker.getDrawable().mutate()), getResources().getColor(R.color.yellow));

    initMarqueeView1();
    initMarqueeView2();
    initMarqueeView3();
    initMarqueeView4();
    initMarqueeView5();
    initMarqueeView6();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:MainActivity.java

示例3: getTintedDrawable

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static Drawable getTintedDrawable(Context context,
    @DrawableRes int id, @AttrRes int tintAttrId) {
  boolean attributeFound = context.getTheme().resolveAttribute(tintAttrId, VALUE, true);
  if (!attributeFound) {
    throw new Resources.NotFoundException("Required tint color attribute with name "
        + context.getResources().getResourceEntryName(tintAttrId)
        + " and attribute ID "
        + tintAttrId
        + " was not found.");
  }

  Drawable drawable = ContextCompat.getDrawable(context, id);
  drawable = DrawableCompat.wrap(drawable.mutate());
  int color = ContextCompat.getColor(context, VALUE.resourceId);
  DrawableCompat.setTint(drawable, color);
  return drawable;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:Utils.java

示例4: setTint

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:MDTintHelper.java

示例5: initializeView

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
private void initializeView() {
    Context context = getContext();
    frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp);
    frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable);
    DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector));

    rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp);
    rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable);
    DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector));

    setBackgroundResource(R.drawable.circle_frame_background_dark);
    displayBackCamera();

    padding = Utils.convertDipToPixels(context, padding);
    setPadding(padding, padding, padding, padding);

    displayBackCamera();
}
 
开发者ID:florent37,项目名称:CameraFragment,代码行数:19,代码来源:CameraSwitchView.java

示例6: setBackgroundDrawable

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
void setBackgroundDrawable(ColorStateList backgroundTint, Mode backgroundTintMode, int rippleColor, int borderWidth) {
    Drawable[] layers;
    this.mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(this.mShapeDrawable, backgroundTint);
    if (backgroundTintMode != null) {
        DrawableCompat.setTintMode(this.mShapeDrawable, backgroundTintMode);
    }
    this.mRippleDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(this.mRippleDrawable, createColorStateList(rippleColor));
    if (borderWidth > 0) {
        this.mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
        layers = new Drawable[]{this.mBorderDrawable, this.mShapeDrawable, this.mRippleDrawable};
    } else {
        this.mBorderDrawable = null;
        layers = new Drawable[]{this.mShapeDrawable, this.mRippleDrawable};
    }
    this.mContentBackground = new LayerDrawable(layers);
    this.mShadowDrawable = new ShadowDrawableWrapper(this.mView.getResources(), this.mContentBackground, this.mShadowViewDelegate.getRadius(), this.mElevation, this.mElevation + this.mPressedTranslationZ);
    this.mShadowDrawable.setAddPaddingForCorners(false);
    this.mShadowViewDelegate.setBackgroundDrawable(this.mShadowDrawable);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:FloatingActionButtonEclairMr1.java

示例7: tint

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的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

示例8: setIconColor

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
/**
 * Set a color of icon on left side.
 *
 * @param iconColor a icon color
 */
public void setIconColor(@ColorInt final int iconColor) {
    mIconColor = iconColor;
    if (mDisplayMode == MODE_ICON && mIconView.getDrawable() != null) {
        ViewUtils.setIconColor(mIconView,
                Color.alpha(mIconColor) == 0 ? mDefaultColor : mIconColor);

    } else if (mDisplayMode == MODE_CIRCULAR_ICON
            && mCircularIconView.getIconDrawable() != null) {
        mCircularIconView.setMask(Color.alpha(mIconColor) == 0);
        Drawable wrappedDrawable = DrawableCompat.wrap(mCircularIconView.getIconDrawable());
        DrawableCompat.setTint(wrappedDrawable,
                Color.alpha(mIconColor) == 0 ? Color.WHITE : mIconColor);
        mCircularIconView.setIconDrawable(wrappedDrawable);
    }
}
 
开发者ID:lurbas,项目名称:ListItemView,代码行数:21,代码来源:ListItemView.java

示例9: drawableToBitmap

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
public Bitmap drawableToBitmap(Drawable drawable) {
    Bitmap bitmap = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && (drawable instanceof VectorDrawable || drawable instanceof VectorDrawableCompat)) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            drawable = (DrawableCompat.wrap(drawable)).mutate();
        }

        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        drawable.draw(canvas);
    } else if (drawable instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) drawable).getBitmap();
    }
    return bitmap;
}
 
开发者ID:gsantner,项目名称:memetastic,代码行数:18,代码来源:ContextUtils.java

示例10: init

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
        TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ColorRatingBar, defStyleAttr, 0);
        int progressColor = a.getColor(R.styleable.ColorRatingBar_progress_color, ContextCompat.getColor(context, R.color.colorPrimary));
//        int halfColor = a.getColor(R.styleable.ColorRatingBar_half_color, ContextCompat.getColor(context, R.color.colorAccent));
        int emptyColor = a.getColor(R.styleable.ColorRatingBar_empty_color, ContextCompat.getColor(context, R.color.colorAccent));
        boolean changeable = a.getBoolean(R.styleable.ColorRatingBar_changeable, true);

        LayerDrawable stars = (LayerDrawable) getProgressDrawable();
        // Filled stars
        setRatingStarColor(DrawableCompat.wrap(stars.getDrawable(2)), progressColor);
        // Half filled stars
        setRatingStarColor(DrawableCompat.wrap(stars.getDrawable(1)), progressColor);
        // Empty stars
        setRatingStarColor(DrawableCompat.wrap(stars.getDrawable(0)), emptyColor);

        setIsIndicator(!changeable);
    }
 
开发者ID:hyogeunpark,项目名称:ColorRatingBar,代码行数:18,代码来源:ColorRatingBar.java

示例11: initializeView

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
private void initializeView() {
        photoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_photo_camera_white_24dp);
        photoDrawable = DrawableCompat.wrap(photoDrawable);
        DrawableCompat.setTintList(photoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector));

        videoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_videocam_white_24dp);
        videoDrawable = DrawableCompat.wrap(videoDrawable);
        DrawableCompat.setTintList(videoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector));

        setBackgroundResource(R.drawable.circle_frame_background_dark);
//        setBackgroundResource(R.drawable.circle_frame_background);

        setOnClickListener(new MediaActionClickListener());
        setIcons();
        padding = Utils.convertDipToPixels(context, padding);
        setPadding(padding, padding, padding, padding);
    }
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:18,代码来源:MediaActionSwitchView.java

示例12: applyButtonTint

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的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

示例13: bind

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
public void bind(ServerListAdapter adapter, ServerConnectionInfo connectionInfo) {
    mConnectionInfo = connectionInfo;

    Drawable d = DrawableCompat.wrap(mIconBg.getBackground());
    if (connectionInfo.isConnected()) {
        DrawableCompat.setTint(d, adapter.mColorConnected);
        mIcon.setImageResource(R.drawable.ic_server_connected);
        int channels = connectionInfo.getChannels().size();
        mDesc.setText(mDesc.getResources().getQuantityString(R.plurals.server_list_connected, channels, channels));
    } else if (connectionInfo.isConnecting()) {
        DrawableCompat.setTint(d, adapter.mColorConnecting);
        mIcon.setImageResource(R.drawable.ic_refresh);
        mDesc.setText(R.string.server_list_connecting);
    } else {
        DrawableCompat.setTint(d, adapter.mColorDisconnected);
        mIcon.setImageResource(R.drawable.ic_close);
        mDesc.setText(R.string.server_list_disconnected);
    }
    mIconBg.setBackgroundDrawable(d);
    mName.setText(connectionInfo.getName());
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:22,代码来源:ServerListAdapter.java

示例14: setStyle

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
void setStyle(TextSection section) {
    switch (section.getAlignment()) {
        case TextSection.LEFT:
            DrawableCompat.setTint(mImageAlignLeft.getDrawable(), 0xff24cf5f);
            DrawableCompat.setTint(mImageAlignCenter.getDrawable(), 0xFFFFFFFF);
            DrawableCompat.setTint(mImageAlignRight.getDrawable(), 0xFFFFFFFF);
            break;
        case TextSection.CENTER:
            DrawableCompat.setTint(mImageAlignLeft.getDrawable(), 0xFFFFFFFF);
            DrawableCompat.setTint(mImageAlignCenter.getDrawable(), 0xff24cf5f);
            DrawableCompat.setTint(mImageAlignRight.getDrawable(), 0xFFFFFFFF);
            break;
        case TextSection.RIGHT:
            DrawableCompat.setTint(mImageAlignLeft.getDrawable(), 0xFFFFFFFF);
            DrawableCompat.setTint(mImageAlignCenter.getDrawable(), 0xFFFFFFFF);
            DrawableCompat.setTint(mImageAlignRight.getDrawable(), 0xff24cf5f);
            break;
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:20,代码来源:AlignPopupWindow.java

示例15: positionSelectorLikeFocusCompat

import android.support.v4.graphics.drawable.DrawableCompat; //导入依赖的package包/类
protected void positionSelectorLikeFocusCompat(int position, View sel) {
    boolean manageState;
    boolean z = true;
    Drawable selector = getSelector();
    if (selector == null || position == -1) {
        manageState = false;
    } else {
        manageState = true;
    }
    if (manageState) {
        selector.setVisible(false, false);
    }
    positionSelectorCompat(position, sel);
    if (manageState) {
        Rect bounds = this.mSelectorRect;
        float x = bounds.exactCenterX();
        float y = bounds.exactCenterY();
        if (getVisibility() != 0) {
            z = false;
        }
        selector.setVisible(z, false);
        DrawableCompat.setHotspot(selector, x, y);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:ListViewCompat.java


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