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


Java ClipDrawable.setColorFilter方法代码示例

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


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

示例1: onShowEggLoadingProgressBar

import android.graphics.drawable.ClipDrawable; //导入方法依赖的package包/类
public void onShowEggLoadingProgressBar(boolean cancelable, int max, int color) {
    mProgress = new ProgressDialog(mContext);
    mProgress.setCancelable(cancelable);
    mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    LayerDrawable layer = (LayerDrawable) ContextCompat.getDrawable(mContext, R.drawable.custom_linear_progress);
    ClipDrawable progress = (ClipDrawable) (layer.findDrawableByLayerId(R.id.progress));
    progress.setColorFilter(color, PorterDuff.Mode.SRC_IN);
    mProgress.setProgressDrawable(layer);
    mProgress.setProgress(0);
    mProgress.setMax(max);
    mProgress.show();
}
 
开发者ID:noosomii,项目名称:EggProgressSDK,代码行数:13,代码来源:EggLoadingProgress.java

示例2: setProgressBarColor

import android.graphics.drawable.ClipDrawable; //导入方法依赖的package包/类
private void setProgressBarColor(int dark) {
    LayerDrawable ld = (LayerDrawable) progressSlider.getProgressDrawable();
    ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress);
    clipDrawable.setColorFilter(dark, PorterDuff.Mode.SRC_IN);
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:6,代码来源:FlatPlaybackControlsFragment.java

示例3: setProgressBarColor

import android.graphics.drawable.ClipDrawable; //导入方法依赖的package包/类
public void setProgressBarColor(SeekBar progressBar, int newColor) {
    LayerDrawable ld = (LayerDrawable) progressBar.getProgressDrawable();
    ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress);
    clipDrawable.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:6,代码来源:PlayerPlaybackControlsFragment.java

示例4: updateTint

import android.graphics.drawable.ClipDrawable; //导入方法依赖的package包/类
private static void updateTint(final Object nowPlayingFragment) throws Throwable {
    if (PREFS.getBoolean(Common.NP_TINT_ICONS, false)) {
        ViewGroup root = (ViewGroup) getObjectField(nowPlayingFragment, "mRootView");
        Object currentState = getObjectField(nowPlayingFragment, "mCurrentState");
        Class exStateClass = findClass(EXPANDING_STATE, nowPlayingFragment.getClass().getClassLoader());
        if (currentState == Enum.valueOf(exStateClass, "FULLY_EXPANDED")) {
            Object artPager = getObjectField(nowPlayingFragment, "mArtPager");
            ArrayList<?> mItems = (ArrayList<?>) getObjectField(artPager, "mItems");
            Object artPageFragment = null;
            for (int i = 0; i < mItems.size(); i++) {
                if (getIntField(mItems.get(i), "position") == (int) callMethod(artPager, "getCurrentItem")) {
                    artPageFragment = getObjectField(mItems.get(i), "object");
                    break;
                }
            }
            // Update color
            if (artPageFragment != null) {
                ImageView mAlbum = (ImageView) getObjectField(artPageFragment, "mAlbum");
                if (mAlbum.getDrawable() != null) {
                    Palette coverPalette = Palette.from(((BitmapDrawable) mAlbum.getDrawable()).getBitmap()).maximumColorCount(16).generate();
                    lastColor = coverPalette.getVibrantColor(Color.parseColor("#9E9E9E"));
                } else {
                    ((Handler) getObjectField(nowPlayingFragment, "mHandler")).postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                updateTint(nowPlayingFragment);
                            } catch (Throwable t) {
                                log(t);
                            }
                        }
                    }, 200);
                    return;
                }
            }
            if (isNewDesignEnabled()) {
                // Tint header bar & its items
                RelativeLayout customHeaderBar = (RelativeLayout) root.findViewById(modRes.getIdentifier("header_bar", "id", XGPM));
                if (customHeaderBar != null) {
                    customHeaderBar.setBackgroundColor(lastColor);
                    RelativeLayout wrapper = (RelativeLayout) customHeaderBar.getChildAt(0);
                    double contrastBlack = ColorUtils.calculateContrast(Color.BLACK, lastColor);
                    double contrastWhite = ColorUtils.calculateContrast(Color.WHITE, lastColor);
                    int imageColor = contrastBlack > contrastWhite ? Color.BLACK : Color.WHITE;
                    for (int j = 0; j < wrapper.getChildCount(); j++) {
                        View current = wrapper.getChildAt(j);
                        if (current instanceof ImageView && current.getId() != root.getResources().getIdentifier("play_pause_header", "id", GPM)) {
                            ((ImageView) current).setColorFilter(imageColor);
                        } else if (current instanceof FrameLayout && ((FrameLayout) current).getChildCount() > 0 &&
                                ((FrameLayout) current).getChildAt(0).getClass().getSimpleName().equals("MediaRouteButton")) {
                            ((Drawable) getObjectField(((FrameLayout) current).getChildAt(0), "mRemoteIndicator")).setColorFilter(imageColor, PorterDuff.Mode.SRC_ATOP);
                        }
                    }
                }
            } else {
                tintQueueButton(nowPlayingFragment);
            }
            // Tint all the rest
            for (Object pager : new Object[]{getObjectField(nowPlayingFragment, "mHeaderPager"), artPager}) {
                if (pager == null)
                    continue;
                for (Object edgeEffectCompat : new Object[]{getObjectField(pager, "mLeftEdge"), getObjectField(pager, "mRightEdge")}) {
                    ((Paint) getObjectField(getObjectField(edgeEffectCompat, "mEdgeEffect"), "mPaint")).setColor(lastColor);
                }
            }
            SeekBar seekBar = (SeekBar) getObjectField(nowPlayingFragment, "mProgress");
            LayerDrawable progress = (LayerDrawable) seekBar.getProgressDrawable().getCurrent();
            ClipDrawable clipProgress = (ClipDrawable) progress.findDrawableByLayerId(root.getResources().getIdentifier("progress", "id", "android"));
            clipProgress.setColorFilter(lastColor, PorterDuff.Mode.SRC_IN);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                AnimatedStateListDrawable thumb = (AnimatedStateListDrawable) seekBar.getThumb();
                thumb.setColorFilter(lastColor, PorterDuff.Mode.SRC_IN);
            }
            ImageButton playPause = (ImageButton) root.findViewById(root.getResources().getIdentifier("pause", "id", GPM));
            playPause.getBackground().setColorFilter(lastColor, PorterDuff.Mode.SRC_ATOP);
        }
    }
}
 
开发者ID:Maxr1998,项目名称:XGPM,代码行数:79,代码来源:NowPlaying.java


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