@Test public void testPopupWindowChangeColor() { mFieldColorView.performClick(); final PopupWindow popupWindow = mFieldColorView.getColorPopupWindow(); final View popupWindowContentView = popupWindow.getContentView(); assertThat(popupWindowContentView).isNotNull(); // Reset color before test. mFieldColor.setColor(0); assertThat(mFieldColor.getColor()).isEqualTo(0); // Simulate click on the color panel. popupWindowContentView.onTouchEvent( MotionEvent.obtain(0 /* downTime */, 0 /* eventTime */, MotionEvent.ACTION_DOWN, 0f /* x */, 0f /* y */, 0 /* metaState */)); // Verify both field and field view background have been set to correct color. final int expectedColour = 0xffffff; assertThat(mFieldColor.getColor()) .isEqualTo(expectedColour); // setColour() masks out alpha. assertThat(((ColorDrawable) mFieldColorView.getBackground()).getColor()) .isEqualTo(BasicFieldColorView.ALPHA_OPAQUE | expectedColour); // Popup window should have disappeared. assertThat(popupWindow.isShowing()).isFalse(); }
@Test public void testErrorDrawableIsSetOnLoadFailed() { Drawable expected = new ColorDrawable(Color.RED); MockTarget target = new MockTarget(); harness.errorDrawable = expected; harness.target = target; SingleRequest<List> request = harness.getRequest(); request.onLoadFailed(new GlideException("test")); assertEquals(expected, target.currentPlaceholder); }
/** * A customized {@link Matcher} for testing that * if one color match the background color of current view. * @param backgroundColor A color int value. * * @return Match or not. */ public static Matcher<View> withBackgroundColor(final int backgroundColor) { return new TypeSafeMatcher<View>() { @Override public boolean matchesSafely(View view) { int color = ((ColorDrawable) view.getBackground().getCurrent()).getColor(); return color == backgroundColor; } @Override public void describeTo(Description description) { description.appendText("with background color value: " + backgroundColor); } }; }
public MenuPopupWindow(Activity context, OnItemClickListener mListener){ LayoutInflater inflater = LayoutInflater.from(context); view = inflater.inflate(R.layout.layout_popup_menu, null); this.mListener = mListener; this.setContentView(view); this.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT); //设置SelectPicPopupWindow弹出窗体的高 this.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT); //设置SelectPicPopupWindow弹出窗体可点击 this.setFocusable(false); this.setOutsideTouchable(true); this.setBackgroundDrawable(new ColorDrawable(0x00000000)); view.findViewById(R.id.lay_share).setOnClickListener(this); view.findViewById(R.id.lay_inform).setOnClickListener(this); }
private void setupUserAutocomplete() { EditText edit = (EditText) findViewById(R.id.single); float elevation = 6f; Drawable backgroundDrawable = new ColorDrawable(Color.WHITE); AutocompletePresenter<User> presenter = new UserPresenter(this); AutocompleteCallback<User> callback = new AutocompleteCallback<User>() { @Override public boolean onPopupItemClicked(Editable editable, User item) { editable.clear(); editable.append(item.getFullname()); return true; } public void onPopupVisibilityChanged(boolean shown) {} }; userAutocomplete = Autocomplete.<User>on(edit) .with(elevation) .with(backgroundDrawable) .with(presenter) .with(callback) .build(); }
@Test public void testErrorDrawableSetOnNullModelWithErrorDrawable() { Drawable placeholder = new ColorDrawable(Color.RED); Drawable errorPlaceholder = new ColorDrawable(Color.GREEN); MockTarget target = new MockTarget(); harness.placeholderDrawable = placeholder; harness.errorDrawable = errorPlaceholder; harness.target = target; harness.model = null; SingleRequest<List> request = harness.getRequest(); request.begin(); assertEquals(errorPlaceholder, target.currentPlaceholder); }
@Override @NonNull protected LinearLayout makeCenterView() { LinearLayout rootLayout = new LinearLayout(activity); rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); rootLayout.setBackgroundColor(Color.WHITE); rootLayout.setOrientation(LinearLayout.VERTICAL); ListView listView = new ListView(activity); listView.setBackgroundColor(Color.WHITE); listView.setDivider(new ColorDrawable(0xFFDDDDDD)); listView.setDividerHeight(1); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setSelector(R.color.itemSelected); listView.setCacheColorHint(Color.TRANSPARENT); listView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)); listView.setAdapter(adapter); listView.setOnItemClickListener(this); rootLayout.addView(listView); return rootLayout; }
private void initView() { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar))); } mCoordinatorLayout = findViewById(R.id.coordinator); RecyclerView recyclerView = findViewById(R.id.recycle_view); recyclerView.setLayoutManager(new LinearLayoutManager(this)); RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator(); if (animator instanceof DefaultItemAnimator) { ((DefaultItemAnimator) animator).setSupportsChangeAnimations(false); } mAdapter = new CancelAdapter(this, new ArrayList<DayLesson>()); @SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView); recyclerView.setAdapter(animatorAdapter); ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter); ItemTouchHelper touchHelper = new ItemTouchHelper(callback); touchHelper.attachToRecyclerView(recyclerView); mView_FABMenu = findViewById(R.id.fab_menu_1); mView_FABMenu.setVisibility(View.GONE); }
public void changeActionBarColor(int newColor) { int color = newColor != 0 ? newColor : SettingsActivity.getPrimaryColor(this); Drawable colorDrawable = new ColorDrawable(color); if (oldBackground == null) { getSupportActionBar().setBackgroundDrawable(colorDrawable); } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, colorDrawable }); getSupportActionBar().setBackgroundDrawable(td); td.startTransition(200); } oldBackground = colorDrawable; }
public static void tintViewDrawable(View view, Drawable drawable, TintInfo tint) { if (view == null || drawable == null) return; if (tint.mHasTintList || tint.mHasTintMode) { drawable.mutate(); if (drawable instanceof ColorDrawable) { ((ColorDrawable) drawable).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList.getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor()))); } else { drawable.setColorFilter(createTintFilter(view.getContext(), tint.mHasTintList ? tint.mTintList : null, tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE, view.getDrawableState())); } } else { drawable.clearColorFilter(); } if (Build.VERSION.SDK_INT <= 23) { // On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter // has changed, so we need to force an invalidation drawable.invalidateSelf(); } }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Idea from here // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html Dialog dialog = new Dialog(mContext); Window window = dialog.getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); window.setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); return dialog; }
public static Dialog showConfirmDialog(Activity activity, boolean cancelable, String title, String message, final CustomAlertOnClickListener backHandler) { Dialog dialog = new Dialog(activity, R.style.CustomDialog); dialog.setContentView(R.layout.confirm_dialog); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setCancelable(cancelable); TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_title); TextView tvContent = (TextView) dialog.findViewById(R.id.tv_content); Button btnBack = (Button) dialog.findViewById(R.id.btn_confirm); if (!TextUtils.isEmpty(title)) { tvTitle.setText(title); } tvContent.setText(message); dialog.show(); final Dialog inDialog = dialog; btnBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (backHandler != null) { backHandler.onClick(inDialog, v); } } }); return dialog; }
public Attributes(Context context) { mContext = context; this.background = new ColorDrawable(Color.TRANSPARENT); this.cancelButtonBackground = new ColorDrawable(Color.BLACK); ColorDrawable gray = new ColorDrawable(Color.GRAY); this.otherButtonTopBackground = gray; this.otherButtonMiddleBackground = gray; this.otherButtonBottomBackground = gray; this.otherButtonSingleBackground = gray; this.cancelButtonTextColor = Color.WHITE; this.otherButtonTextColor = Color.BLACK; this.padding = dp2px(20); this.otherButtonSpacing = dp2px(2); this.cancelButtonMarginTop = dp2px(10); this.actionSheetTextSize = dp2px(16); }
@Override public void finishNativeInitialization() { // The window background color is used as the resizing background color in Android N+ // multi-window mode. See crbug.com/602366. if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { getWindow().setBackgroundDrawable(new ColorDrawable( ApiCompatibilityUtils.getColor(getResources(), R.color.resizing_background_color))); } else { removeWindowBackground(); } DownloadManagerService.getDownloadManagerService( getApplicationContext()).onActivityLaunched(); super.finishNativeInitialization(); }
@SuppressLint("InflateParams") ImageFolderPopupWindow(Context context, Callback callback) { super(LayoutInflater.from(context).inflate(R.layout.popup_window_folder, null), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); mCallback = callback; // init setAnimationStyle(R.style.popup_anim_style_alpha); setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); setOutsideTouchable(true); setFocusable(true); // content View content = getContentView(); content.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); content.addOnAttachStateChangeListener(this); mFolderView = (RecyclerView) content.findViewById(R.id.rv_popup_folder); mFolderView.setLayoutManager(new LinearLayoutManager(context)); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // the content final RelativeLayout root = new RelativeLayout(getActivity()); root.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // creating the fullscreen dialog final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(root); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.getWindow().setLayout( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } dialog.setCanceledOnTouchOutside(false); return dialog; }
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(false);//触摸屏幕取消窗体 dialog.setCancelable(false);//按返回键取消窗体 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); }
public static CustomPowerMenu getWritePowerMenu(Context context, LifecycleOwner lifecycleOwner, OnMenuItemClickListener onMenuItemClickListener) { ColorDrawable drawable = new ColorDrawable(context.getResources().getColor(R.color.md_blue_grey_300)); return new CustomPowerMenu.Builder<>(context, new CenterMenuAdapter()) .addItem("Novel") .addItem("Poetry") .addItem("Art") .addItem("Journals") .addItem("Travel") .setLifecycleOwner(lifecycleOwner) .setAnimation(MenuAnimation.FADE) .setMenuRadius(10f) .setMenuShadow(10f) .setDivider(drawable) .setDividerHeight(1) .setOnMenuItemClickListener(onMenuItemClickListener) .build(); }
@Override protected void setColor(int color) { int darkColor = VideoInfoCommonClass.getDarkerColor(color); ColorDrawable[] colord = {new ColorDrawable(mLastColor), new ColorDrawable(darkColor)}; TransitionDrawable trans = new TransitionDrawable(colord); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) mApplicationFrameLayout.setBackground(trans); else mApplicationFrameLayout.setBackgroundDrawable(trans); trans.startTransition(200); mLastColor = darkColor; if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) { getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getActivity().getWindow().setStatusBarColor(VideoInfoCommonClass.getAlphaColor(darkColor, 160)); } }
@Test public void load_withColorDrawable_fixedSize_functionalBitmapTransform_doesNotRecycleOutput() throws ExecutionException, InterruptedException { Drawable colorDrawable = new ColorDrawable(Color.RED); int width = 100; int height = 200; Drawable result = GlideApp.with(context) .load(colorDrawable) .circleCrop() .override(width, height) .submit() .get(); BitmapSubject.assertThat(result).isNotRecycled(); BitmapPool bitmapPool = Glide.get(context).getBitmapPool(); // Make sure we didn't put the same Bitmap twice. Bitmap first = bitmapPool.get(width, height, Config.ARGB_8888); Bitmap second = bitmapPool.get(width, height, Config.ARGB_8888); assertThat(first).isNotSameAs(second); }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final RelativeLayout root = new RelativeLayout(getActivity()); root.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // creating the fullscreen dialog final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(root); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.getWindow().setLayout( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } dialog.setCanceledOnTouchOutside(false); return dialog; }
/** * Creates a new drawable (implementation of the Drawable object may vary depending on the OS version). * The result Drawable will be colored with the given color, and clipped to match the given bounds. * Note that the drawable's alpha is set to 0 when argument color is {@link Color#TRANSPARENT}. * * @param color Integer color used to color the output drawable * @param bounds Four-dimensional vector representing drawable bounds * @return Colored and clipped drawable object */ @NonNull public static Drawable createColoredDrawable(@ColorInt final int color, @Nullable final Rect bounds) { // create the drawable depending on the OS (pre-Honeycomb couldn't use color drawables inside state lists) Drawable drawable; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || bounds != null) { drawable = new GradientDrawable(Orientation.BOTTOM_TOP, new int[] { color, color }).mutate(); } else { drawable = new ColorDrawable(color).mutate(); } // set the alpha value if (color == Color.TRANSPARENT) { drawable.setAlpha(0); } // update bounds if (bounds != null) { drawable.setBounds(bounds); } return drawable; }
public EntityHeaderController styleActionBar(AppCompatActivity activity) { if (activity == null) { Log.w(TAG, "No activity, cannot style actionbar."); return this; } final ActionBar actionBar = activity.getSupportActionBar(); if (actionBar == null) { Log.w(TAG, "No actionbar, cannot style actionbar."); return this; } actionBar.setBackgroundDrawable( new ColorDrawable(Utils.getColorAttr(activity, R.attr.colorSettings))); actionBar.setElevation(0); //if (mRecyclerView != null && mLifecycle != null) { // ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView); //} return this; }
public void onCreate() { activity.getWindow().setBackgroundDrawable(new ColorDrawable(0x4c000000)); sivViewer = new ScaledImageView(activity); sivViewer.setScaleType(ScaleType.MATRIX); activity.setContentView(sivViewer); if (pic != null) { sivViewer.getViewTreeObserver().addOnGlobalLayoutListener(this); } }
public GraphListView(Context ctx) { super(ctx); setCacheColorHint(0xFFFFFFFF); setBackgroundColor(0xFFFFFFFF); setDivider(new ColorDrawable(0xFF898989)); setDividerHeight(1); db_ = SeismoDbAdapter.getAdapter(); db_.open(ctx); graph_names_ = db_.fetchGraphNames(); adapter_ = new ArrayAdapter<String>(ctx, R.layout.export, graph_names_); setAdapter(adapter_); db_.close(); }
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { //noinspection ConstantConditions getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); View view = inflater.inflate(R.layout.dialog_settings, container, false); swSolidRow = (SwitchCompat) view.findViewById(R.id.swSolidRow); swFixedHeaders = (SwitchCompat) view.findViewById(R.id.swFixedHeaders); swRtlDirection = (SwitchCompat) view.findViewById(R.id.swRtlDirection); swDragAndDropEnabled = (SwitchCompat) view.findViewById(R.id.swDragAndDropEnabled); return view; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.rc_ac_contact_detail); getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); initView(); initData(); }
public BucketAdapter( List<BucketBean> bucketList, Configuration configuration, @ColorInt int color) { this.mBucketList = bucketList; this.mConfiguration = configuration; this.mDefaultImage = new ColorDrawable(color); }
private Bitmap getBitmapFromDrawable(Drawable drawable) { if (drawable == null) { return null; } if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } try { Bitmap bitmap; if (drawable instanceof ColorDrawable) { bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; } catch (Exception e) { e.printStackTrace(); return null; } }
private static Drawable getUnableStateDrawable(Context context, @NonNull Drawable unable) { if (isKitkat() && !(unable instanceof ColorDrawable)) { return kitkatUnableDrawable(context, unable); } unable.setAlpha(convertAlphaToInt(0.5f)); return unable; }
private void createPopupFolderList(int width, int height) { folderPopupWindow = new ListPopupWindow(getActivity()); folderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); folderPopupWindow.setAdapter(folderListAdapter); folderPopupWindow.setContentWidth(width); folderPopupWindow.setWidth(width); folderPopupWindow.setHeight(height); folderPopupWindow.setAnchorView(rlBottom); folderPopupWindow.setModal(true); folderListAdapter.setOnFloderChangeListener(new OnFolderChangeListener() { @Override public void onChange(int position, Folder folder) { folderPopupWindow.dismiss(); if (position == 0) { getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback); btnAlbumSelected.setText("所有图片"); } else { imageList.clear(); if (config.needCamera) imageList.add(new Image()); imageList.addAll(folder.images); imageListAdapter.notifyDataSetChanged(); btnAlbumSelected.setText(folder.name); } } }); }
private Bitmap getBitmap() { Drawable drawable = getDrawable(); if (drawable == null) { return null; } if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } try { Bitmap bitmap; if (drawable instanceof ColorDrawable) { bitmap = Bitmap.createBitmap(COLOR_DRAWABLE_DIMEN, COLOR_DRAWABLE_DIMEN, BITMAP_CONFIG); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; } catch (Exception e) { e.printStackTrace(); return null; } }
@Override public void onStart() { super.onStart(); getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); Window window = getDialog().getWindow(); WindowManager.LayoutParams windowParams = window.getAttributes(); windowParams.dimAmount = 0.0f; window.setAttributes(windowParams); getDialog().getWindow() .setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); int headTextColor; if (Build.VERSION.SDK_INT >= 23) { headTextColor = getResources().getColor(R.color.setup_item_head_text, null); } else { headTextColor = getResources().getColor(R.color.setup_item_head_text); } toolbar.setTitleTextColor(headTextColor); setSupportActionBar(toolbar); int headColor; if (Build.VERSION.SDK_INT >= 23) { headColor = getResources().getColor(R.color.setup_item_head, null); } else { headColor = getResources().getColor(R.color.setup_item_head); } getSupportActionBar().setTitle("총공 설정"); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(headColor)); getFragmentManager().beginTransaction() .replace(R.id.frame, new AttackSettingFragment()) .commit(); }
public void onStart() { super.onStart(); Window window = getDialog().getWindow(); LayoutParams params = window.getAttributes(); params.gravity = 80; params.width = -1; params.height = DensityUtil.dip2px(getActivity(), 480.0f); window.setAttributes(params); window.setBackgroundDrawable(new ColorDrawable(0)); }
@Test public void testSetsTransitionDrawableIfPreviousIsNotNull() { Drawable previous = new ColorDrawable(Color.WHITE); when(harness.adapter.getCurrentDrawable()).thenReturn(previous); harness.animation.transition(harness.current, harness.adapter); verify(harness.adapter).setDrawable(any(TransitionDrawable.class)); }
private void setupActionBar() { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // Show the Up button in the action bar. actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(PIBLUE))); } }
private Bitmap getBitmapFromDrawable(Drawable drawable) { if (drawable == null) { return null; } if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } try { Bitmap bitmap; if (drawable instanceof ColorDrawable) { bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG); } else { bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG); } Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); return bitmap; } catch (OutOfMemoryError e) { return null; } }
public void displayRemoteProvisioningInProgressDialog() { remoteProvisioningInProgress = true; progress = ProgressDialog.show(this, null, null); Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorE)); d.setAlpha(200); progress.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); progress.getWindow().setBackgroundDrawable(d); progress.setContentView(R.layout.progress_dialog); progress.show(); }
public PlayTopPopupWindow(Context context, int height) { this.context = context; View view = LayoutInflater.from(context).inflate(R.layout.play_top_menu, null); rgSubtitle = findById(R.id.rg_subtitle, view); rgScreenSize = findById(R.id.rg_screensize, view); popupWindow = new PopupWindow(view, height * 2 / 3, height); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(178, 0, 0, 0))); }