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);
}
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;
}
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);
}
}
});
}
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);
}
}
}
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() {
}
});
}
Aggregations