List of usage examples for android.graphics.drawable TransitionDrawable TransitionDrawable
public TransitionDrawable(Drawable[] layers)
From source file:com.pendtium.base.fragments.BaseFragment.java
protected void changeActionBarColor(int color) { Drawable colorDrawable = new ColorDrawable(color); Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { // if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { // ld.setCallback(drawableCallback); // } else { activity.getSupportActionBar().setBackgroundDrawable(ld); // } } else {/* w w w .j av a 2s . c o m*/ TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); // workaround for broken ActionBarContainer drawable handling on // pre-API 17 builds // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { activity.getSupportActionBar().setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; }
From source file:cn.psvmc.demo.MainActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);/* w w w . j a va 2 s . c o m*/ ActionBar actionbar = getActionBar(); if (actionbar == null) { return; } // change ActionBar color just if an ActionBar is available if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { ld.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(ld); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(true); } currentColor = newColor; }
From source file:jahirfiquitiva.iconshowcase.adapters.WallpapersAdapter.java
@Override public void onBindViewHolder(final WallsHolder holder, int position) { final WallpaperItem wallItem = wallsList.get(position); ViewCompat.setTransitionName(holder.wall, "transition" + position); holder.name.setText(wallItem.getWallName()); holder.authorName.setText(wallItem.getWallAuthor()); final String wallUrl = wallItem.getWallURL(); String wallThumb = wallItem.getWallThumbUrl(); BitmapImageViewTarget target = new BitmapImageViewTarget(holder.wall) { @Override/*from w w w . j av a2 s . co m*/ protected void setResource(Bitmap resource) { Palette.Swatch wallSwatch = ColorExtractor.getProminentSwatch(resource, false); boolean animsEnabled = mPrefs.getAnimationsEnabled(); if (animsEnabled) { TransitionDrawable td = new TransitionDrawable( new Drawable[] { new ColorDrawable(Color.TRANSPARENT), new BitmapDrawable(context.getResources(), resource) }); holder.wall.setImageDrawable(td); td.startTransition(250); } else { holder.wall.setImageBitmap(resource); } if (wallSwatch != null) { if (animsEnabled) { TransitionDrawable td = new TransitionDrawable(new Drawable[] { holder.titleBg.getBackground(), new ColorDrawable(wallSwatch.getRgb()) }); holder.titleBg.setBackground(td); td.startTransition(250); } else { holder.titleBg.setBackgroundColor(wallSwatch.getRgb()); } holder.name.setTextColor(wallSwatch.getBodyTextColor()); holder.authorName.setTextColor(wallSwatch.getTitleTextColor()); } } }; if (!(wallThumb.equals("null"))) { Glide.with(context).load(wallUrl).asBitmap() .thumbnail(Glide.with(context).load(wallThumb).asBitmap().thumbnail(0.3f)).into(target); } else { Glide.with(context).load(wallUrl).asBitmap().thumbnail(0.4f).into(target); } }
From source file:mj.com.myapplication.MainActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);//from w ww . ja v a 2s . c o m // change ActionBar color just if an ActionBar is available if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { ld.setCallback(drawableCallback); } else { //getActionBar().setBackgroundDrawable(ld); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); // workaround for broken ActionBarContainer drawable handling on // pre-API 17 builds // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { //getActionBar().setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler //getActionBar().setDisplayShowTitleEnabled(false); //getActionBar().setDisplayShowTitleEnabled(true); } currentColor = newColor; }
From source file:com.example.pagerslidingtabstrip.MainActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);/* w w w . j ava 2 s. com*/ // change ActionBar color just if an ActionBar is available if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { ld.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(ld); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); // workaround for broken ActionBarContainer drawable handling on // pre-API 17 builds // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler } currentColor = newColor; }
From source file:com.zoe.viewpager.MainActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);//w w w.java 2s .c om // ActionBarActionBar if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { ld.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(ld); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); // workaround for broken ActionBarContainer drawable handling on // pre-API 17 builds // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(true); } currentColor = newColor; }
From source file:me.priyesh.chromasample.MainActivity.java
private void updateToolbar(int oldColor, int newColor) { final TransitionDrawable transition = new TransitionDrawable( new ColorDrawable[] { new ColorDrawable(oldColor), new ColorDrawable(newColor) }); mToolbar.setBackground(transition);/*ww w. j a v a2 s . c o m*/ transition.startTransition(300); }
From source file:com.romelapj.appvercine.activity.MainActivity.java
private void changeColor(int newColor) { tabs.setBackgroundColor(newColor);/*from www .jav a2 s .c om*/ mTintManager.setTintColor(newColor); Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = new ColorDrawable(getResources().getColor(android.R.color.transparent)); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { getSupportActionBar().setBackgroundDrawable(ld); } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); getSupportActionBar().setBackgroundDrawable(td); td.startTransition(200); } }
From source file:com.duguang.baseanimation.ui.tab.PagerTabStrip.PagerTabMainActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);/*from w w w. ja v a 2s. co m*/ // change ActionBar color just if an ActionBar is available if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = getResources().getDrawable(R.drawable.tab_pagertab_actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { ld.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(ld); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); // workaround for broken ActionBarContainer drawable handling on // pre-API 17 builds // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(true); } currentColor = newColor; }
From source file:com.marshalchen.common.demoofui.viewpagerSlidingTab.ViewpagerSlidingTabsActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);/* w w w . j av a2 s .c om*/ // change ActionBar color just if an ActionBar is available if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = getResources().getDrawable(R.drawable.view_sliding_tab_actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { ld.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(ld); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); // workaround for broken ActionBarContainer drawable handling on // pre-API 17 builds // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(true); } currentColor = newColor; }