CmBatteryBar.java 文件源码

java
阅读 88 收藏 0 点赞 0 评论 0

项目:Noyze 作者:
/**
 * Updates the {@link ShapeDrawable} which displays the
 * color of the bar across the screen.
 */
public void setProgressDrawable(Drawable mDrawable, int mNewColor)
{
    if (mDrawable instanceof LayerDrawable &&
        getProgressDrawable() instanceof LayerDrawable)
    {
        final LayerDrawable mDraw = (LayerDrawable) getProgressDrawable();
        final ClipDrawable mShape = (ClipDrawable)
            mDraw.findDrawableByLayerId(android.R.id.progress);

        // Make sure we've got everything.
        if (mShape != null && mProgress != null &&
            mProgress.getPaint() != null)
        {
            mProgress.getPaint().setColor(mNewColor);
            final Rect mBounds = mDraw.getBounds();
            super.setProgressDrawable(mDraw);
            getProgressDrawable().setBounds(mBounds);
            return;
        }
    }

    super.setProgressDrawable(mDrawable);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号