List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable
public ColorDrawable(@ColorInt int color)
From source file:android.bitmap.util.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./*from w w w .j a v a 2 s. com*/ * * @param imageView * @param drawable */ @SuppressWarnings("deprecation") private void setImageDrawable(ImageView imageView, Drawable drawable) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:com.example.com.jglx.android.app.util.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//from ww w .j a v a2 s . co m * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final // drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:com.android.project.imagefetcher.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set * on the ImageView.// ww w. j a va 2s .c o m * * @param imageView * @param bitmap */ @SuppressWarnings("deprecation") private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Transition drawable with a transparent drwabale and the final // bitmap final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.appeaser.sublimenavigationviewlibrary.SublimeThemer.java
private void setDefaultDrawerBackground() { TypedValue value = new TypedValue(); if (mContext.getTheme().resolveAttribute(android.R.attr.colorBackground, value, true)) { mDrawerBackground = new ColorDrawable(value.data); } else {/*from w w w. ja v a2 s. c o m*/ mDrawerBackground = new ColorDrawable(mDefaultTheme == DefaultTheme.LIGHT ? mContext.getResources().getColor(R.color.snv_background_material_light) : mContext.getResources().getColor(R.color.snv_background_material_dark)); } }
From source file:com.github.programmerr47.vkgroups.imageloading.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//from w w w. ja v a 2 s. com */ private void setImageDrawable(ImageView imageView, BitmapDrawable drawable, LoadBitmapParams loadingParams) { Drawable finalDrawable = postProcessDrawable(drawable, loadingParams); if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(imageView.getResources().getColor(android.R.color.transparent)), finalDrawable }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(finalDrawable); } }
From source file:com.afollestad.polar.ui.MainActivity.java
private void setupNavDrawer() { assert mNavView != null; assert mDrawer != null; mNavView.getMenu().clear();/*ww w .j av a 2 s . c om*/ for (PagesBuilder.Page page : mPages) page.addToMenu(mNavView.getMenu()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getWindow().setStatusBarColor(Color.TRANSPARENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mDrawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { //TODO: Check if NavigationView needs bottom padding WindowInsets drawerLayoutInsets = insets.replaceSystemWindowInsets( insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), 0); mDrawerModeTopInset = drawerLayoutInsets.getSystemWindowInsetTop(); ((DrawerLayout) v).setChildInsets(drawerLayoutInsets, drawerLayoutInsets.getSystemWindowInsetTop() > 0); return insets; } }); } assert getSupportActionBar() != null; getSupportActionBar().setDisplayHomeAsUpEnabled(true); Drawable menuIcon = VC.get(R.drawable.ic_action_menu); menuIcon = TintUtils.createTintedDrawable(menuIcon, DialogUtils.resolveColor(this, R.attr.tab_icon_color)); getSupportActionBar().setHomeAsUpIndicator(menuIcon); mDrawer.addDrawerListener( new ActionBarDrawerToggle(this, mDrawer, mToolbar, R.string.drawer_open, R.string.drawer_close)); mDrawer.setStatusBarBackgroundColor(DialogUtils.resolveColor(this, R.attr.colorPrimaryDark)); mNavView.setNavigationItemSelectedListener(this); final ColorDrawable navBg = (ColorDrawable) mNavView.getBackground(); final int selectedIconText = DialogUtils.resolveColor(this, R.attr.colorAccent); int iconColor; int titleColor; int selectedBg; if (TintUtils.isColorLight(navBg.getColor())) { iconColor = ContextCompat.getColor(this, R.color.navigationview_normalicon_light); titleColor = ContextCompat.getColor(this, R.color.navigationview_normaltext_light); selectedBg = ContextCompat.getColor(this, R.color.navigationview_selectedbg_light); } else { iconColor = ContextCompat.getColor(this, R.color.navigationview_normalicon_dark); titleColor = ContextCompat.getColor(this, R.color.navigationview_normaltext_dark); selectedBg = ContextCompat.getColor(this, R.color.navigationview_selectedbg_dark); } final ColorStateList iconSl = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_checked }, new int[] { android.R.attr.state_checked } }, new int[] { iconColor, selectedIconText }); final ColorStateList textSl = new ColorStateList(new int[][] { new int[] { -android.R.attr.state_checked }, new int[] { android.R.attr.state_checked } }, new int[] { titleColor, selectedIconText }); mNavView.setItemTextColor(textSl); mNavView.setItemIconTintList(iconSl); StateListDrawable bgDrawable = new StateListDrawable(); bgDrawable.addState(new int[] { android.R.attr.state_checked }, new ColorDrawable(selectedBg)); mNavView.setItemBackground(bgDrawable); mPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { dispatchFragmentUpdateTitle(false); invalidateNavViewSelection(position); } }); mToolbar.setContentInsetsRelative(getResources().getDimensionPixelSize(R.dimen.second_keyline), 0); }
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void init(AttributeSet attrs) { mHostActivity = Util.getHostActivity(getContext()); LayoutInflater layoutInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); mMainLayout = inflate(getContext(), R.layout.floating_search_layout, this); mBackgroundDrawable = new ColorDrawable(Color.BLACK); mQuerySection = (CardView) findViewById(R.id.search_query_section); mClearButton = (ImageView) findViewById(R.id.clear_btn); mSearchInput = (SearchInputView) findViewById(R.id.search_bar_text); mSearchInputParent = findViewById(R.id.search_input_parent); mLeftAction = (ImageView) findViewById(R.id.left_action); mSearchProgress = (ProgressBar) findViewById(R.id.search_bar_search_progress); initDrawables();// w ww. jav a 2 s. c o m mClearButton.setImageDrawable(mIconClear); mMenuView = (MenuView) findViewById(R.id.menu_view); mDivider = findViewById(R.id.divider); mSuggestionsSection = (RelativeLayout) findViewById(R.id.search_suggestions_section); mSuggestionListContainer = findViewById(R.id.suggestions_list_container); mSuggestionsList = (RecyclerView) findViewById(R.id.suggestions_list); setupViews(attrs); }
From source file:com.cloudsynch.quickshare.utils.thumbnail.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./*from w w w . ja v a 2 s . c om*/ * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final // drawable final TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable }); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }
From source file:com.crazyapk.util.bitmap.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set on the ImageView. * * @param imageView//w w w. jav a 2 s . co m * @param bitmap */ private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Transition drawable with a transparent drwabale and the final bitmap final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.alex.develop.cache.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//from w w w . j a v a 2s. c o m * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable) { if (mFadeInBitmap) { // Transition drawable with a transparent drawable and the final drawable final TransitionDrawable td = new TransitionDrawable(new Drawable[] { // Edit by alex // before new ColorDrawable(android.R.color.transparent), // after // new ColorDrawable(Color.parseColor("#00000000")), // end drawable }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }