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


Java TransitionDrawable類代碼示例

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


TransitionDrawable類屬於android.graphics.drawable包,在下文中一共展示了TransitionDrawable類的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);
    }
}
 
開發者ID:liuyanggithub,項目名稱:SuperSelector,代碼行數:26,代碼來源:ImageWorker.java

示例2: 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(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);
    }
}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:26,代碼來源:ImageWorker.java

示例3: onCreate

import android.graphics.drawable.TransitionDrawable; //導入依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_result);

        final TextView search_result_back = (TextView) findViewById(R.id.search_result_back);
        final ListView search_result_list = (ListView) findViewById(R.id.search_result_list);
        img = (ImageView) findViewById(R.id.imageView3);
        ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, Item.searchList);
        search_result_list.setAdapter(adapter);
        TransitionDrawable animation = (TransitionDrawable)img.getDrawable();
        animation.startTransition(3000);
        animation.reverseTransition(3000);
//        img.setBackgroundResource(R.drawable.trans);
//        AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
//        frameAnimation.start();
        search_result_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Item.searchList.clear();
                goToSearch();
            }
        });
    }
 
開發者ID:IvoryCandy,項目名稱:Plus1s,代碼行數:26,代碼來源:SearchResultActivity.java

示例4: 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

示例5: fadeInDisplay

import android.graphics.drawable.TransitionDrawable; //導入依賴的package包/類
private void fadeInDisplay(ImageView imageView,Bitmap bitmap){
	final TransitionDrawable td =
               new TransitionDrawable(new Drawable[] {
                       new ColorDrawable(android.R.color.transparent),
                       new BitmapDrawable(imageView.getResources(), bitmap)
               });
       imageView.setImageDrawable(td);
       td.startTransition(300);
}
 
開發者ID:PlutoArchitecture,項目名稱:Pluto-Android,代碼行數:10,代碼來源:SimpleDisplayer.java

示例6: 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());
                }
            }
        }
    }
 
開發者ID:IstiN,項目名稱:android-training-2017,代碼行數:16,代碼來源:Malevich.java

示例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();
	}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:18,代碼來源:DocumentsActivity.java

示例8: changeActionBarColor

import android.graphics.drawable.TransitionDrawable; //導入依賴的package包/類
public void changeActionBarColor(int newColor) {

		int color = newColor != 0 ? newColor : 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;
	}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:17,代碼來源:SettingsActivity.java

示例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(400);

        } else {
            mBlurredArt.setImageDrawable(result);
        }
    }
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:18,代碼來源:QuickControlsFragment.java

示例10: 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);
        }
    }
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:18,代碼來源:Timber2.java

示例11: onCreate

import android.graphics.drawable.TransitionDrawable; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.tv_transition).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            TransitionDrawable drawable = (TransitionDrawable) v.getBackground();
            drawable.startTransition(3000);
        }
    });

    ScaleDrawable scaleDrawable = (ScaleDrawable) findViewById(R.id.v_scale).getBackground();
    scaleDrawable.setLevel(10);      //lever默認為0,無法顯示。level範圍為0~10000。level越大,顯示的越大

    ClipDrawable clipDrawable = (ClipDrawable) findViewById(R.id.v_clip).getBackground();
    clipDrawable.setLevel(5000);

    View vCustom = findViewById(R.id.v_custom);
    CustomDrawable customDrawable = new CustomDrawable(getResources().getColor(R.color.colorAccent));
    vCustom.setBackground(customDrawable);
}
 
開發者ID:DysaniazzZ,項目名稱:ArtOfAndroid,代碼行數:24,代碼來源:MainActivity.java

示例12: 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);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:23,代碼來源:SnippetArticleViewHolder.java

示例13: keyPressed

import android.graphics.drawable.TransitionDrawable; //導入依賴的package包/類
protected void keyPressed() {
    if (isEnabled() && isClickable()) {
        Drawable selector = this.mSelector;
        Rect selectorRect = this.mSelectorRect;
        if (selector == null) {
            return;
        }
        if ((isFocused() || touchModeDrawsInPressedState()) && !selectorRect.isEmpty()) {
            View v = getChildAt(this.mSelectedPosition - this.mFirstPosition);
            if (v != null) {
                if (!v.hasFocusable()) {
                    v.setPressed(true);
                } else {
                    return;
                }
            }
            setPressed(true);
            boolean longClickable = isLongClickable();
            Drawable d = selector.getCurrent();
            if (d != null && (d instanceof TransitionDrawable)) {
                if (longClickable) {
                    ((TransitionDrawable) d).startTransition(ViewConfiguration.getLongPressTimeout());
                } else {
                    ((TransitionDrawable) d).resetTransition();
                }
            }
            if (longClickable && !this.mDataChanged) {
                if (this.mPendingCheckForKeyLongPress == null) {
                    this.mPendingCheckForKeyLongPress = new CheckForKeyLongPress(this, null);
                }
                this.mPendingCheckForKeyLongPress.rememberWindowAttachCount();
                postDelayed(this.mPendingCheckForKeyLongPress, (long) ViewConfiguration.getLongPressTimeout());
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:37,代碼來源:AbsHListView.java

示例14: setBlurBackground

import android.graphics.drawable.TransitionDrawable; //導入依賴的package包/類
private void setBlurBackground(Bitmap background) {
        Observable.just(background).map(new Function<Bitmap, TransitionDrawable>() {
            @Override
            public TransitionDrawable apply(Bitmap bitmap) throws Exception {
                return new TransitionDrawable(new Drawable[]{rootView.getBackground(),BlurUtil.createBlurredImageFromBitmap(bitmap, PlayerActivity.this, 20) });
            }
        }).subscribeOn(Schedulers.computation()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<TransitionDrawable>() {
            @Override
            public void accept(TransitionDrawable drawable) throws Exception {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    rootView.setBackground(drawable);
                } else {
                    rootView.setBackgroundDrawable(drawable);
                }
                drawable.startTransition(300);
            }
        });
//        Drawable blurredImageFromBitmap = BlurUtil.createBlurredImageFromBitmap(background, this, 20);

    }
 
開發者ID:piyell,項目名稱:NeteaseCloudMusic,代碼行數:21,代碼來源:PlayerActivity.java

示例15: keyPressed

import android.graphics.drawable.TransitionDrawable; //導入依賴的package包/類
/**
 * Sets the selector state to "pressed" and posts a CheckForKeyLongPress to
 * see if this is a long press.
 */
protected void keyPressed() {
	if (!isEnabled() || !isClickable()) {
		return;
	}

	Drawable selector = mSelector;
	Rect selectorRect = mSelectorRect;
	if (selector != null && (isFocused() || touchModeDrawsInPressedState())
			&& !selectorRect.isEmpty()) {

		final View v = getChildAt(mSelectedPosition - mFirstPosition);

		if (v != null) {
			if (v.hasFocusable())
				return;
			v.setPressed(true);
		}
		setPressed(true);

		final boolean longClickable = isLongClickable();
		Drawable d = selector.getCurrent();
		if (d != null && d instanceof TransitionDrawable) {
			if (longClickable) {
				((TransitionDrawable) d).startTransition(ViewConfiguration
						.getLongPressTimeout());
			} else {
				((TransitionDrawable) d).resetTransition();
			}
		}
		if (longClickable && !mDataChanged) {
			if (mPendingCheckForKeyLongPress == null) {
				mPendingCheckForKeyLongPress = new CheckForKeyLongPress();
			}
			mPendingCheckForKeyLongPress.rememberWindowAttachCount();
			postDelayed(mPendingCheckForKeyLongPress,
					ViewConfiguration.getLongPressTimeout());
		}
	}
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:44,代碼來源:AbsHListView.java


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