当前位置: 首页>>代码示例>>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;未经允许,请勿转载。