Search in sources :

Example 41 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project AndroidPicker by gzu-liyujiang.

the class BasicPopup method initDialog.

private void initDialog() {
    contentLayout = new FrameLayout(activity);
    contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
    contentLayout.setFocusable(true);
    contentLayout.setFocusableInTouchMode(true);
    //contentLayout.setFitsSystemWindows(true);
    dialog = new Dialog(activity);
    //触摸屏幕取消窗体
    dialog.setCanceledOnTouchOutside(true);
    //按返回键取消窗体
    dialog.setCancelable(true);
    dialog.setOnKeyListener(this);
    dialog.setOnDismissListener(this);
    Window window = dialog.getWindow();
    if (window != null) {
        window.setGravity(Gravity.BOTTOM);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        //AndroidRuntimeException: requestFeature() must be called before adding content
        window.requestFeature(Window.FEATURE_NO_TITLE);
        window.setContentView(contentLayout);
    }
    setSize(screenWidthPixels, WRAP_CONTENT);
}
Also used : Window(android.view.Window) ColorDrawable(android.graphics.drawable.ColorDrawable) ViewGroup(android.view.ViewGroup) Dialog(android.app.Dialog) FrameLayout(android.widget.FrameLayout)

Example 42 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project AndroidPicker by gzu-liyujiang.

the class ConvertUtils method toBitmap.

/**
     * 将Drawable转换为Bitmap
     * 参考:http://kylines.iteye.com/blog/1660184
     */
public static Bitmap toBitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof ColorDrawable) {
        //color
        Bitmap bitmap = Bitmap.createBitmap(32, 32, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.drawColor(((ColorDrawable) drawable).getColor());
        return bitmap;
    } else if (drawable instanceof NinePatchDrawable) {
        //.9.png
        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    }
    return null;
}
Also used : Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) Canvas(android.graphics.Canvas) BitmapDrawable(android.graphics.drawable.BitmapDrawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 43 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project ListenerMusicPlayer by hefuyicoder.

the class PanelSlideListener method setBlurredAlbumArt.

private void setBlurredAlbumArt() {
    Observable.create(new Observable.OnSubscribe<Drawable>() {

        @Override
        public void call(Subscriber<? super Drawable> subscriber) {
            Bitmap bitmap = ((BitmapDrawable) albumImage.getDrawable()).getBitmap();
            Drawable drawable = ImageUtil.createBlurredImageFromBitmap(bitmap, mContext, 3);
            subscriber.onNext(drawable);
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Drawable>() {

        @Override
        public void call(Drawable drawable) {
            CoordinatorLayout.LayoutParams imageLayout = (CoordinatorLayout.LayoutParams) albumImage.getLayoutParams();
            imageLayout.height = FrameLayout.LayoutParams.MATCH_PARENT;
            imageLayout.width = FrameLayout.LayoutParams.MATCH_PARENT;
            albumImage.setLayoutParams(imageLayout);
            albumImage.setImageDrawable(drawable);
            if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
                ColorDrawable colorDrawable = new ColorDrawable(nowPlayingCardColor);
                colorDrawable.setAlpha(200);
                albumImage.setForeground(colorDrawable);
            }
        }
    });
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) Subscriber(rx.Subscriber) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 44 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project iosched by google.

the class SessionDetailFragment method displayTrackColor.

/**
     * Update the header box background color & status bar color depending upon which track this
     * session belongs to.
     * <p>
     * Note this requires both the {@link SessionDetailQueryEnum#SESSIONS} &
     * {@link SessionDetailQueryEnum#TAG_METADATA) queries to have returned.
     */
private void displayTrackColor(SessionDetailModel data) {
    if (data.isSessionTrackColorAvailable()) {
        int trackColor = data.getSessionTrackColor();
        if (trackColor == Color.TRANSPARENT) {
            trackColor = UIUtils.getThemeColor(getContext(), R.attr.colorPrimary, R.color.theme_primary);
        }
        final Drawable background = mHeaderBox.getBackground();
        if (background instanceof ColorDrawable && ((ColorDrawable) background).getColor() == trackColor) {
            return;
        }
        // Animate the color change to make the transition smoother
        final ObjectAnimator color = ObjectAnimator.ofInt(mHeaderBox, UIUtils.BACKGROUND_COLOR, trackColor);
        color.setEvaluator(new ArgbEvaluator());
        if (mHasEnterTransition) {
            color.setStartDelay(200L);
        }
        color.setDuration(300L);
        color.start();
        if (mCollapsingToolbar.getFitsSystemWindows() && mPhotoViewContainer.getVisibility() == View.VISIBLE) {
            // immersive+photo
            mCollapsingToolbar.setStatusBarScrimColor(trackColor);
        } else {
            UIUtils.adjustAndSetStatusBarColor(getActivity(), trackColor);
        }
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable)

Example 45 with ColorDrawable

use of android.graphics.drawable.ColorDrawable in project SimpleNews by liuling07.

the class SwipeBackActivityHelper method onActivityCreate.

@SuppressWarnings("deprecation")
public void onActivityCreate() {
    mActivity.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    mActivity.getWindow().getDecorView().setBackgroundDrawable(null);
    mSwipeBackLayout = (SwipeBackLayout) LayoutInflater.from(mActivity).inflate(me.imid.swipebacklayout.lib.R.layout.swipeback_layout, null);
    mSwipeBackLayout.addSwipeListener(new SwipeBackLayout.SwipeListener() {

        @Override
        public void onScrollStateChange(int state, float scrollPercent) {
        }

        @Override
        public void onEdgeTouch(int edgeFlag) {
            Utils.convertActivityToTranslucent(mActivity);
        }

        @Override
        public void onScrollOverThreshold() {
        }
    });
}
Also used : SwipeBackLayout(me.imid.swipebacklayout.lib.SwipeBackLayout) ColorDrawable(android.graphics.drawable.ColorDrawable)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)530 View (android.view.View)113 Drawable (android.graphics.drawable.Drawable)103 BitmapDrawable (android.graphics.drawable.BitmapDrawable)69 ImageView (android.widget.ImageView)62 TextView (android.widget.TextView)55 Bitmap (android.graphics.Bitmap)52 AdapterView (android.widget.AdapterView)32 LinearLayout (android.widget.LinearLayout)32 Test (org.junit.Test)31 Canvas (android.graphics.Canvas)30 ListView (android.widget.ListView)27 FrameLayout (android.widget.FrameLayout)23 ViewGroup (android.view.ViewGroup)22 Handler (android.os.Handler)20 Paint (android.graphics.Paint)19 StateListDrawable (android.graphics.drawable.StateListDrawable)19 TransitionDrawable (android.graphics.drawable.TransitionDrawable)19 WindowManager (android.view.WindowManager)17 Intent (android.content.Intent)16