本文整理匯總了Java中android.graphics.drawable.TransitionDrawable.startTransition方法的典型用法代碼示例。如果您正苦於以下問題:Java TransitionDrawable.startTransition方法的具體用法?Java TransitionDrawable.startTransition怎麽用?Java TransitionDrawable.startTransition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.TransitionDrawable
的用法示例。
在下文中一共展示了TransitionDrawable.startTransition方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setImageDrawable
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
/**
* Called when the processing is complete and the final drawable should be
* set on the ImageView.
*
* @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);
}
}
示例2: setImageBitmap
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
public void setImageBitmap(@Nullable final Drawable fromDrawable, @Nullable final Bitmap toBitmap) {
final int width = getMeasuredWidth();
final int height = getMeasuredHeight();
Runnable runnable = new Runnable() {
@Override
public void run() {
final TransitionDrawable td = new TransitionDrawable(new Drawable[]{
fromDrawable, new BitmapDrawable(getResources(),
getScaleType() == ScaleType.CENTER_CROP ?
centerCrop(getResources(), toBitmap, width, height) :
toBitmap)});
RImageView.super.setImageDrawable(td);
td.startTransition(300);
}
};
if (width == 0 || height == 0) {
post(runnable);
} else {
runnable.run();
}
}
示例3: crossfadeTargetBackground
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private void crossfadeTargetBackground(PaletteTarget target, Pair<View, Integer> t, int newColor) {
final Drawable oldColor = t.first.getBackground();
final Drawable[] drawables = new Drawable[2];
drawables[0] = oldColor != null ? oldColor : new ColorDrawable(t.first.getSolidColor());
drawables[1] = new ColorDrawable(newColor);
TransitionDrawable transitionDrawable = new TransitionDrawable(drawables);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
t.first.setBackground(transitionDrawable);
} else {
//noinspection deprecation
t.first.setBackgroundDrawable(transitionDrawable);
}
transitionDrawable.startTransition(target.targetCrossfadeSpeed);
}
示例4: processImageResult
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private void processImageResult(ImageResult imageResult) {
if (imageResult != null) {
ImageRequest request = imageResult.getRequest();
ImageView imageView = request.target.get();
if (imageView != null) {
Object tag = imageView.getTag();
if (tag != null && tag.equals(request.url)) {
TransitionDrawable drawable = new TransitionDrawable(new Drawable[]{EMPTY_DRAWABLE, new BitmapDrawable(imageResult.getBitmap())});
imageView.setImageDrawable(drawable);
drawable.startTransition(1000);
// imageView.setImageBitmap(imageResult.getBitmap());
}
}
}
}
示例5: 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);
}
示例6: onPostExecute
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
@Override
protected void onPostExecute(Drawable result) {
if (result != null) {
if (mBlurredArt.getDrawable() != null) {
final TransitionDrawable td =
new TransitionDrawable(new Drawable[]{
mBlurredArt.getDrawable(),
result
});
mBlurredArt.setImageDrawable(td);
td.startTransition(400);
} else {
mBlurredArt.setImageDrawable(result);
}
}
}
示例7: changeActionBarColor
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private void changeActionBarColor() {
int color = 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;
setUpStatusBar();
}
示例8: repeatTransition
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
void repeatTransition(final TransitionDrawable trans, final int timeInterval) {
r = new Runnable() {
@Override
public void run() {
if (flag) {
// Log.d("tagg", "straight");
trans.startTransition(timeInterval);
flag = false;
} else {
// Log.d("tagg", "reverse");
trans.reverseTransition(timeInterval);
flag = true;
}
hand.postDelayed(this, (2*timeInterval));
}
};
hand.post(r);
}
示例9: onPostExecute
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
@Override
protected void onPostExecute(Drawable result) {
if (result != null) {
if (mBlurredArt.getDrawable() != null) {
final TransitionDrawable td =
new TransitionDrawable(new Drawable[]{
mBlurredArt.getDrawable(),
result
});
mBlurredArt.setImageDrawable(td);
td.startTransition(200);
} else {
mBlurredArt.setImageDrawable(result);
}
}
}
示例10: setColor
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
@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));
}
}
示例11: open
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
void open()
{
ColorDrawable[] color = {new ColorDrawable(Color.parseColor("#00ffffff")), new ColorDrawable(Color.parseColor("#CC000000"))};
TransitionDrawable trans = new TransitionDrawable(color);
//This will work also on old devices. The latest API says you have to use setBackground instead.
rel.setBackgroundDrawable(trans);
trans.startTransition(100);
//rel.setBackgroundColor(Color.parseColor("#CC000000"));
web.setVisibility(View.VISIBLE);
fb.setVisibility(View.VISIBLE);
email.setVisibility(View.VISIBLE);
webtxt.setVisibility(View.VISIBLE);
fbtxt.setVisibility(View.VISIBLE);
emailtxt.setVisibility(View.VISIBLE);
}
示例12: setContent
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private void setContent() {
setContentView(R.layout.activity_login);
screen = (RelativeLayout)findViewById(R.id.rl);
ColorDrawable[] color = {new ColorDrawable(getResources().getColor(R.color.colorAccent)), new ColorDrawable(getResources().getColor(R.color.colorPrimary)) };
TransitionDrawable trans = new TransitionDrawable(color);
screen.setBackgroundDrawable(trans);
trans.startTransition(1800);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
mGoogleApiClient = new GoogleApiClient.Builder(getBaseContext())
.enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
mAuth = FirebaseAuth.getInstance();
FirebaseDatabase database = FirebaseDatabase.getInstance();
root= database.getReference("room_names");
loadRooms();
new CountDownTimer(2500, 1000) {
public void onTick(long millisUntilDone) { }
public void onFinish() {
currentUser = mAuth.getCurrentUser();
updateUI(currentUser);
}
}.start();
}
示例13: display
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
/**
* @param bitmap
* @param imageView
*/
public void display(Bitmap bitmap, ImageView imageView) {
Drawable oldDrawable = imageView.getDrawable();
Drawable oldBitmapDrawable = null;
//如果原先的imageView沒drawable就創建一個透明的drawable
if (null == oldDrawable) {
oldBitmapDrawable = new ColorDrawable(Color.TRANSPARENT);
}
//如果原先就是TransitionDrawable,就獲得第二張圖片
else if (oldDrawable instanceof TransitionDrawable) {
oldBitmapDrawable = ((TransitionDrawable) oldDrawable).getDrawable(1);
} else {
oldBitmapDrawable = oldDrawable;
}
TransitionDrawable td = new TransitionDrawable(new Drawable[]{
oldBitmapDrawable,
new BitmapDrawable(Resources.getSystem(), bitmap)
});
imageView.setImageDrawable(td);
td.startTransition(durationMillis);
}
示例14: setImageBitmap
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
/**
* Called when the processing is complete and the final bitmap should be set on the ImageView.
*
* @param imageView The ImageView to set the bitmap to.
* @param bitmap The new bitmap to set.
*/
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
if (mFadeInBitmap) {
// Transition drawable to fade from loading bitmap to final bitmap
final TransitionDrawable td =
new TransitionDrawable(new Drawable[]{
new ColorDrawable(android.R.color.transparent),
new BitmapDrawable(mResources, bitmap)
});
imageView.setBackgroundDrawable(imageView.getDrawable());
imageView.setImageDrawable(td);
td.startTransition(FADE_IN_TIME);
} else {
imageView.setImageBitmap(bitmap);
}
}
示例15: fadeThumbnailIn
import android.graphics.drawable.TransitionDrawable; //導入方法依賴的package包/類
private void fadeThumbnailIn(SnippetArticle snippet, Bitmap thumbnail) {
mImageCallback = null;
if (thumbnail == null) return; // Nothing to do, we keep the placeholder.
// We need to crop and scale the downloaded bitmap, as the ImageView we set it on won't be
// able to do so when using a TransitionDrawable (as opposed to the straight bitmap).
// That's a limitation of TransitionDrawable, which doesn't handle layers of varying sizes.
Resources res = mThumbnailView.getResources();
int targetSize = res.getDimensionPixelSize(R.dimen.snippets_thumbnail_size);
Bitmap scaledThumbnail = ThumbnailUtils.extractThumbnail(
thumbnail, targetSize, targetSize, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
// Store the bitmap to skip the download task next time we display this snippet.
snippet.setThumbnailBitmap(scaledThumbnail);
// Cross-fade between the placeholder and the thumbnail.
Drawable[] layers = {mThumbnailView.getDrawable(),
new BitmapDrawable(mThumbnailView.getResources(), scaledThumbnail)};
TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
mThumbnailView.setImageDrawable(transitionDrawable);
transitionDrawable.startTransition(FADE_IN_ANIMATION_TIME_MS);
}