當前位置: 首頁>>代碼示例>>Java>>正文


Java TransitionDrawable.setCrossFadeEnabled方法代碼示例

本文整理匯總了Java中android.graphics.drawable.TransitionDrawable.setCrossFadeEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java TransitionDrawable.setCrossFadeEnabled方法的具體用法?Java TransitionDrawable.setCrossFadeEnabled怎麽用?Java TransitionDrawable.setCrossFadeEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.TransitionDrawable的用法示例。


在下文中一共展示了TransitionDrawable.setCrossFadeEnabled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transition

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
/**
 * Animates from the previous drawable to the current drawable in one of two ways.
 *
 * <ol> <li>Using the default animation provided in the constructor if the previous drawable is
 * null</li> <li>Using the cross fade animation with the duration provided in the constructor if
 * the previous drawable is non null</li> </ol>
 *
 * @param current {@inheritDoc}
 * @param adapter {@inheritDoc}
 * @return {@inheritDoc}
 */
@Override
public boolean transition(Drawable current, ViewAdapter adapter) {
  Drawable previous = adapter.getCurrentDrawable();
  if (previous != null) {
    TransitionDrawable transitionDrawable =
        new TransitionDrawable(new Drawable[] { previous, current });
    transitionDrawable.setCrossFadeEnabled(isCrossFadeEnabled);
    transitionDrawable.startTransition(duration);
    adapter.setDrawable(transitionDrawable);
    return true;
  } else {
    defaultAnimation.transition(current, adapter);
    return false;
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:DrawableCrossFadeTransition.java

示例2: startTrans

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private void startTrans(int targetPosition, ImageView targetImage, RecyclingBitmapDrawable startBp, RecyclingBitmapDrawable endBp) {
    if (endBp == null)
        endBp = loadBitmap(targetPosition);
    TransitionDrawable td = new TransitionDrawable(new Drawable[] {startBp, endBp});
    targetImage.setImageDrawable(td);
    td.setCrossFadeEnabled(true);
    td.startTransition(mSwitchAnimTime);
}
 
開發者ID:codeestX,項目名稱:ECardFlow,代碼行數:9,代碼來源:ECardFlowLayout.java

示例3: onPostExecute

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
@Override protected void onPostExecute(Bitmap bitmap) {
  runningLoader.getAndSet(null);

  if (viewRef.get() == null) {
    return;
  }

  View view = viewRef.get();
  Drawable originalBackground = view.getBackground();
  if (originalBackground instanceof BitmapDrawable) {
    Bitmap bmp = ((BitmapDrawable) originalBackground).getBitmap();

    if (bitmap != bmp && !cachedDensityBitmaps.containsValue(bmp)) {
      bmp.recycle();
      System.gc();
    }
  }

  TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[] {
      new ColorDrawable(Color.BLACK), new BitmapDrawable(view.getResources(), bitmap)
  });
  view.setBackground(transitionDrawable);

  transitionDrawable.setCrossFadeEnabled(true);
  transitionDrawable.startTransition(500);
}
 
開發者ID:ozodrukh,項目名稱:IUT-E-class,代碼行數:27,代碼來源:BlurBackgroundView.java

示例4: onFinishInflate

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    mOriginalTextColor = getTextColors();

    // Get the hover color
    Resources r = getResources();
    mHoverColor = r.getColor(R.color.info_target_hover_tint);
    mDrawable = (TransitionDrawable) getCurrentDrawable();
    if (null != mDrawable) {
        mDrawable.setCrossFadeEnabled(true);
    }

    // Remove the text in the Phone UI in landscape
    int orientation = getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (!LauncherAppState.getInstance().isScreenLarge()) {
            setText("");
        }
    }
}
 
開發者ID:Phonemetra,項目名稱:TurboLauncher,代碼行數:23,代碼來源:InfoDropTarget.java

示例5: setFadingImageDrawable

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
/**
 * Start a transition to the new image
 *
 * @param drawable the drawable to set
 */
public void setFadingImageDrawable(Drawable drawable) {
    Drawable currentDrawable = getDrawable();
    if ((currentDrawable != null) && (currentDrawable instanceof TransitionDrawable)) {
        currentDrawable = ((TransitionDrawable) currentDrawable).getDrawable(1);
    }
    if (currentDrawable != null) {
        Drawable[] arrayDrawable = new Drawable[2];
        arrayDrawable[0] = currentDrawable;
        arrayDrawable[1] = drawable;
        TransitionDrawable transitionDrawable = new TransitionDrawable(arrayDrawable);
        transitionDrawable.setCrossFadeEnabled(true);
        setImageDrawable(transitionDrawable);
        transitionDrawable.startTransition(transitionDurationMillis);
    } else {
        setImageDrawable(drawable);
    }
}
 
開發者ID:dexlex,項目名稱:DexMovingImageView,代碼行數:23,代碼來源:DexCrossFadeImageView.java

示例6: onFinishInflate

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    // Get the drawable
    mOriginalTextColor = getTextColors();

    // Get the hover color
    Resources r = getResources();
    mHoverColor = r.getColor(R.color.delete_target_hover_tint);
    mUninstallDrawable = (TransitionDrawable) 
            r.getDrawable(R.drawable.uninstall_target_selector);
    mRemoveDrawable = (TransitionDrawable) r.getDrawable(R.drawable.remove_target_selector);

    mRemoveDrawable.setCrossFadeEnabled(true);
    mUninstallDrawable.setCrossFadeEnabled(true);

    // The current drawable is set to either the remove drawable or the uninstall drawable 
    // and is initially set to the remove drawable, as set in the layout xml.
    mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();
}
 
開發者ID:krajeswaran,項目名稱:LeanLauncher,代碼行數:22,代碼來源:DeleteDropTarget.java

示例7: animate

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private void animate(final int firstDrawable, int secondDrawable, final int duration) {
    if(secondDrawable >= drawables.length) {
        secondDrawable = 0;
    }

    setDrawables(drawables, firstDrawable, secondDrawable);

    mFirst = ContextCompat.getDrawable(context, drawables[firstDrawable]);
    mSecond = ContextCompat.getDrawable(context, drawables[secondDrawable]);

    final TransitionDrawable mTransitionDrawable = new TransitionDrawable(new Drawable[] {mFirst, mSecond});

    if(Build.VERSION.SDK_INT >= 17) {
        target.setBackground(mTransitionDrawable);
    } else {
        target.setBackgroundDrawable(mTransitionDrawable);
    }

    mTransitionDrawable.setCrossFadeEnabled(false);
    mTransitionDrawable.startTransition(duration);

    final int mLocalSecondDrawable = secondDrawable;
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            animate(mLocalSecondDrawable, mLocalSecondDrawable + 1, randomInt(MIN, MAX));
        }
    }, duration);
}
 
開發者ID:dsa28s,項目名稱:TimeSkyBackground,代碼行數:30,代碼來源:SkyViewGradientBackgroundPainter.java

示例8: fadeBackground

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
/**
 * Fade the ActionBar background from oldDrawable to newDrawable
 *
 * @param oldDrawable Drawable to be faded from
 * @param newDrawable Drawable to be faded to
 * @return Instance of this class
 */
private ActionBarBackground fadeBackground(Drawable oldDrawable, Drawable newDrawable) {
    if (oldDrawable == null) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
            newDrawable.setCallback(drawableCallback);
        } else {
            mActionBar.setBackgroundDrawable(newDrawable);
        }
    } else {
        TransitionDrawable td = new TransitionDrawable(new Drawable[]{oldDrawable, newDrawable});
        td.setCrossFadeEnabled(true);

        // 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 {
            int paddingTop = mToolbar.getPaddingTop();
            mActionBar.setBackgroundDrawable(td);
            mToolbar.setPadding(mToolbar.getPaddingLeft(), paddingTop, mToolbar.getPaddingRight(), mToolbar.getPaddingBottom()); // fix for fitSystemWindows
        }

        td.startTransition(500);
    }

    mOldBackground = newDrawable;

    // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler
    //mActionBar.setDisplayShowTitleEnabled(false);
    //mActionBar.setDisplayShowTitleEnabled(true);

    return this;
}
 
開發者ID:PTCE,項目名稱:popcorn-android,代碼行數:41,代碼來源:ActionBarBackground.java

示例9: getImageListener

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
public static ImageLoader.ImageListener getImageListener(
        final Resources r, final ImageView iv, final Drawable defDrawable, final Drawable errorDrawable) {

    return new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorDrawable != null) {
                iv.setImageDrawable(errorDrawable);
            }
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                if (!isImmediate && defDrawable != null) {
                    TransitionDrawable transitionDrawable = new TransitionDrawable(
                            new Drawable[]{
                                    defDrawable,
                                    new BitmapDrawable(r, response.getBitmap())
                            }
                    );
                    transitionDrawable.setCrossFadeEnabled(true);
                    iv.setImageDrawable(transitionDrawable);
                    transitionDrawable.startTransition(100);
                } else {
                    iv.setImageBitmap(response.getBitmap());
                }
            } else if (defDrawable != null) {
                iv.setImageDrawable(defDrawable);
            }
        }
    };
}
 
開發者ID:duanze,項目名稱:Meizitu,代碼行數:34,代碼來源:ImageCacheManager.java

示例10: setBmAnimate

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation, float ratio, float anchor, int source){
	
	bm = filter(iv, bm, fallback);
	if(bm == null){
		iv.setImageBitmap(null);
		return;
	}
	
	Drawable d = makeDrawable(iv, bm, ratio, anchor);
	Animation anim = null;
	
	if(fadeIn(animation, source)){	
		if(preset == null){
			anim = new AlphaAnimation(0, 1);
			anim.setInterpolator(new DecelerateInterpolator()); 
			anim.setDuration(FADE_DUR);
		}else{
			
			Drawable pd = makeDrawable(iv, preset, ratio, anchor);
			Drawable[] ds = new Drawable[]{pd, d};
			TransitionDrawable td = new TransitionDrawable(ds);
			td.setCrossFadeEnabled(true);				
			td.startTransition(FADE_DUR);
			d = td;
		}
	}else if(animation > 0){
		anim = AnimationUtils.loadAnimation(iv.getContext(), animation);
	}
	
	iv.setImageDrawable(d);
	
	if(anim != null){
		anim.setStartTime(AnimationUtils.currentAnimationTimeMillis());		
		iv.startAnimation(anim);
	}else{
		iv.setAnimation(null);
	}
}
 
開發者ID:bblue000,項目名稱:ExoPlayerDemo,代碼行數:39,代碼來源:BitmapAjaxCallback.java

示例11: createFadeInDrawable

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private TransitionDrawable createFadeInDrawable(Bitmap paramBitmap)
{
  Drawable[] arrayOfDrawable = new Drawable[2];
  arrayOfDrawable[0] = new ColorDrawable(0);
  arrayOfDrawable[1] = new BitmapDrawable(this.mContext.getResources(), paramBitmap);
  TransitionDrawable localTransitionDrawable = new TransitionDrawable(arrayOfDrawable);
  localTransitionDrawable.setCrossFadeEnabled(true);
  localTransitionDrawable.startTransition(250);
  return localTransitionDrawable;
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:11,代碼來源:ScreenshotsModule.java

示例12: setControlsBackground

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private void setControlsBackground(Drawable paramDrawable, boolean paramBoolean)
{
  if ((paramBoolean) && (USE_ANIMATIONS))
  {
    Drawable localDrawable = this.mControlsContainer.getBackground();
    if (localDrawable == null) {
      localDrawable = makeNonFloatingBackground();
    }
    if (paramDrawable == null) {
      paramDrawable = makeNonFloatingBackground();
    }
    if (localDrawable == paramDrawable) {
      return;
    }
    TransitionDrawable local6 = new TransitionDrawable(new Drawable[] { localDrawable, paramDrawable })
    {
      @TargetApi(21)
      public final void getOutline(Outline paramAnonymousOutline)
      {
        paramAnonymousOutline.setRect(getBounds());
        paramAnonymousOutline.setAlpha(1.0F);
      }
    };
    local6.setCrossFadeEnabled(true);
    local6.startTransition(300);
    this.mControlsContainer.setBackgroundDrawable(local6);
    return;
  }
  this.mControlsContainer.setBackgroundDrawable(paramDrawable);
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:31,代碼來源:PlayHeaderListLayout.java

示例13: getImageListener

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
public static ImageLoader.ImageListener getImageListener(final ImageView view,
                                                         final Drawable defaultImageDrawable, final Drawable errorImageDrawable) {
    return new ImageLoader.ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageDrawable != null) {
                view.setImageDrawable(errorImageDrawable);
            }
        }

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                if (!isImmediate && defaultImageDrawable != null) {
                    TransitionDrawable transitionDrawable = new TransitionDrawable(
                            new Drawable[]{
                                    defaultImageDrawable,
                                    new BitmapDrawable(App.getContext().getResources(),
                                            response.getBitmap())
                            }
                    );
                    transitionDrawable.setCrossFadeEnabled(true);
                    view.setImageDrawable(transitionDrawable);
                    transitionDrawable.startTransition(100);
                } else {
                    view.setImageBitmap(response.getBitmap());
                }
            } else if (defaultImageDrawable != null) {
                view.setImageDrawable(defaultImageDrawable);
            }
        }
    };
}
 
開發者ID:SparkYuan,項目名稱:Material-9GAG,代碼行數:34,代碼來源:ImageCacheManager.java

示例14: onFinishInflate

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    // Get the drawable
    mOriginalTextColor = getTextColors();

    // Get the hover color
    Resources r = getResources();
    mHoverColor = r.getColor(R.color.delete_target_hover_tint);
    mUninstallDrawable = (TransitionDrawable) 
            r.getDrawable(R.drawable.uninstall_target_selector);
    mRemoveDrawable = (TransitionDrawable) r.getDrawable(R.drawable.remove_target_selector);

    mRemoveDrawable.setCrossFadeEnabled(true);
    mUninstallDrawable.setCrossFadeEnabled(true);

    // The current drawable is set to either the remove drawable or the uninstall drawable 
    // and is initially set to the remove drawable, as set in the layout xml.
    mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();

    // Remove the text in the Phone UI in landscape
    int orientation = getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (!LauncherAppState.getInstance().isScreenLarge()) {
            setText("");
        }
    }
}
 
開發者ID:Phonemetra,項目名稱:TurboLauncher,代碼行數:30,代碼來源:DeleteDropTarget.java

示例15: crossfadeDrawable

import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private TransitionDrawable crossfadeDrawable(Drawable from, Drawable to) {
    Drawable[] arrayDrawable = new Drawable[2];
    arrayDrawable[0] = from;
    arrayDrawable[1] = to;
    TransitionDrawable transitionDrawable = new TransitionDrawable(arrayDrawable);
    transitionDrawable.setCrossFadeEnabled(true);
    return transitionDrawable;
}
 
開發者ID:jameliu,項目名稱:Camera2,代碼行數:9,代碼來源:BottomBar.java


注:本文中的android.graphics.drawable.TransitionDrawable.setCrossFadeEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。