本文整理汇总了Java中android.transition.Transition类的典型用法代码示例。如果您正苦于以下问题:Java Transition类的具体用法?Java Transition怎么用?Java Transition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transition类属于android.transition包,在下文中一共展示了Transition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeTargets
import android.transition.Transition; //导入依赖的package包/类
public static void removeTargets(Object transitionObject, ArrayList<View> views) {
Transition transition = (Transition) transitionObject;
int i;
if (transition instanceof TransitionSet) {
TransitionSet set = (TransitionSet) transition;
int numTransitions = set.getTransitionCount();
for (i = 0; i < numTransitions; i++) {
removeTargets(set.getTransitionAt(i), views);
}
} else if (!hasSimpleTarget(transition)) {
List<View> targets = transition.getTargets();
if (targets != null && targets.size() == views.size() && targets.containsAll(views)) {
for (i = views.size() - 1; i >= 0; i--) {
transition.removeTarget((View) views.get(i));
}
}
}
}
示例2: addTargets
import android.transition.Transition; //导入依赖的package包/类
public static void addTargets(Object transitionObject, ArrayList<View> views) {
Transition transition = (Transition) transitionObject;
int i;
if (transition instanceof TransitionSet) {
TransitionSet set = (TransitionSet) transition;
int numTransitions = set.getTransitionCount();
for (i = 0; i < numTransitions; i++) {
addTargets(set.getTransitionAt(i), views);
}
} else if (!hasSimpleTarget(transition) && isNullOrEmpty(transition.getTargets())) {
int numViews = views.size();
for (i = 0; i < numViews; i++) {
transition.addTarget((View) views.get(i));
}
}
}
示例3: onCreate
import android.transition.Transition; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= 21)
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
setContentView(R.layout.activity_window_transitions_second);
Transition transition = TransitionInflater
.from(this)
// .inflateTransition(R.transition.explode); /* 爆炸效果 */
// .inflateTransition(R.transition.fade); /* 淡化效果 */
.inflateTransition(R.transition.slide); /* 滑动效果 */
/* 退出时使用 */
getWindow().setExitTransition(transition);
/* 第一次进入时使用 */
getWindow().setEnterTransition(transition);
}
示例4: onCreate
import android.transition.Transition; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= 21)
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
setContentView(R.layout.activity_window_transitions);
Transition transition = TransitionInflater
.from(this)
.inflateTransition(R.transition.explode); /* 爆炸效果 */
// .inflateTransition(R.transition.fade); /* 淡化效果 */
// .inflateTransition(R.transition.slide); /* 滑动效果 */
/* 退出时使用 */
getWindow().setExitTransition(transition);
/* 再次进入时使用 */
getWindow().setReenterTransition(transition);
/* 第一次进入时使用 */
getWindow().setEnterTransition(transition);
}
示例5: applyTransitionToWindow
import android.transition.Transition; //导入依赖的package包/类
static void applyTransitionToWindow(@NonNull final Window window,
@NonNull final Transition transition,
boolean enter, boolean retun,
boolean reenter, boolean exit,
boolean overlap) {
window.setAllowEnterTransitionOverlap(overlap);
window.setAllowReturnTransitionOverlap(overlap);
if (enter) {
window.setEnterTransition(transition);
}
if (reenter) {
window.setReenterTransition(transition);
}
if (exit) {
window.setExitTransition(transition);
}
if (retun) {
window.setReturnTransition(transition);
}
}
示例6: navigateToArtist
import android.transition.Transition; //导入依赖的package包/类
@TargetApi(21)
public static void navigateToArtist(Activity context, long artistID, Pair<View, String> transitionViews) {
FragmentTransaction transaction = ((AppCompatActivity) context).getSupportFragmentManager().beginTransaction();
Fragment fragment;
if (TimberUtils.isLollipop() && transitionViews != null && PreferencesUtility.getInstance(context).getAnimations()) {
Transition changeImage = TransitionInflater.from(context).inflateTransition(R.transition.image_transform);
transaction.addSharedElement(transitionViews.first, transitionViews.second);
fragment = ArtistDetailFragment.newInstance(artistID, true, transitionViews.second);
fragment.setSharedElementEnterTransition(changeImage);
} else {
transaction.setCustomAnimations(R.anim.activity_fade_in,
R.anim.activity_fade_out, R.anim.activity_fade_in, R.anim.activity_fade_out);
fragment = ArtistDetailFragment.newInstance(artistID, false, null);
}
transaction.hide(((AppCompatActivity) context).getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.add(R.id.fragment_container, fragment);
transaction.addToBackStack(null).commit();
}
示例7: constructTransitions
import android.transition.Transition; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private TransitionSet constructTransitions() {
int[] slideTargets = {R.id.ChatRecyclerView, R.id.chat_input, R.id.chat_input_divider};
Transition slideTransition = new Slide(Gravity.BOTTOM);
Transition fadeTransition = new Fade();
for (int slideTarget : slideTargets) {
slideTransition.addTarget(slideTarget);
fadeTransition.excludeTarget(slideTarget, true);
}
TransitionSet set = new TransitionSet();
set.addTransition(slideTransition);
set.addTransition(fadeTransition);
return set;
}
示例8: createSlideAnimation
import android.transition.Transition; //导入依赖的package包/类
@SuppressLint("RtlHardcoded")
private TransitionAnimation createSlideAnimation(boolean forward, AnimationData animationData) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Transition enterTransition = forward ? new Slide(Gravity.RIGHT) : new Slide(Gravity.LEFT);
Transition exitTransition = forward ? new Slide(Gravity.LEFT) : new Slide(Gravity.RIGHT);
LollipopTransitionAnimation animation = new LollipopTransitionAnimation(enterTransition, exitTransition);
animation.setAllowEnterTransitionOverlap(false);
Fragment currentFragment = mActivity.getSupportFragmentManager().findFragmentById(R.id.fragment_container);
if (currentFragment instanceof SharedElementProvider) {
SharedElementProvider sharedElementProvider = (SharedElementProvider) currentFragment;
View sharedElement = sharedElementProvider.getSharedElement(animationData);
String shareElementName = sharedElementProvider.getSharedElementName(animationData);
animation.addSharedElement(sharedElement, shareElementName);
Transition moveTransition = TransitionInflater.from(mActivity).inflateTransition(android.R.transition.move);
moveTransition.setDuration(600);
animation.setSharedElementTransition(moveTransition);
}
return animation;
} else {
int enterAnimRes = forward ? R.anim.slide_in_right : R.anim.slide_in_left;
int exitAnimRes = forward ? R.anim.slide_out_left : R.anim.slide_out_right;
return new SimpleTransitionAnimation(enterAnimRes, exitAnimRes);
}
}
示例9: windowTransition
import android.transition.Transition; //导入依赖的package包/类
private void windowTransition() {
getWindow().getEnterTransition().addListener(new TransitionAdapter(){
@Override
public void onTransitionEnd(Transition transition) {
mAddButton.animate().alpha(1.0f);
getWindow().getEnterTransition().removeListener(this);
}
});
}
示例10: setupTransitions
import android.transition.Transition; //导入依赖的package包/类
public void setupTransitions() {
// Add shared element transition animation if on Lollipop or later
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Enter transitions
TransitionSet setEnter = new TransitionSet();
Transition slideDown = new Explode();
slideDown.addTarget(headerView);
slideDown.excludeTarget(scrollView, true);
slideDown.setDuration(500);
setEnter.addTransition(slideDown);
Transition fadeOut = new Slide(Gravity.BOTTOM);
fadeOut.addTarget(scrollView);
fadeOut.setDuration(500);
setEnter.addTransition(fadeOut);
// Exit transitions
TransitionSet setExit = new TransitionSet();
Transition slideDown2 = new Explode();
slideDown2.addTarget(headerView);
slideDown2.setDuration(570);
setExit.addTransition(slideDown2);
Transition fadeOut2 = new Slide(Gravity.BOTTOM);
fadeOut2.addTarget(scrollView);
fadeOut2.setDuration(280);
setExit.addTransition(fadeOut2);
getWindow().setEnterTransition(setEnter);
getWindow().setReturnTransition(setExit);
}
}
示例11: updateLinkText
import android.transition.Transition; //导入依赖的package包/类
void updateLinkText(String link) {
linkTextView.setText(link);
Transition transition = new AutoTransition()
.setDuration(500)
.setStartDelay(300)
.setInterpolator(new AccelerateDecelerateInterpolator());
TransitionManager.beginDelayedTransition(rootView, transition);
linkTextView.setVisibility(View.VISIBLE);
}
示例12: setSceneTransitionAnimation
import android.transition.Transition; //导入依赖的package包/类
public void setSceneTransitionAnimation() {
if (Build.VERSION.SDK_INT < 21) return;
Transition slide = new Slide(Gravity.RIGHT);
slide.excludeTarget(android.R.id.statusBarBackground, true);
slide.excludeTarget(android.R.id.navigationBarBackground, true);
Window window = getWindow();
window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
window.setExitTransition(slide);
window.setEnterTransition(slide);
window.setTransitionBackgroundFadeDuration(getResources()
.getInteger(android.R.integer.config_longAnimTime));
window.setBackgroundDrawableResource(android.R.color.transparent);
}
示例13: onTransitionStart
import android.transition.Transition; //导入依赖的package包/类
@Override
public void onTransitionStart(@NonNull Transition transition) {
//hide toolbar & statusbar
float toolbar_translationY = -(toolbar.getHeight());
float bottomBar_translationY = ((View) bottomBar.getParent()).getHeight();
toolbar.setTranslationY(toolbar_translationY);
((View) bottomBar.getParent()).setTranslationY(bottomBar_translationY);
super.onTransitionStart(transition);
}
示例14: setEnter
import android.transition.Transition; //导入依赖的package包/类
private void setEnter()
{
enterTransitionListener = new Transition.TransitionListener()
{
@Override
public void onTransitionStart(Transition transition)
{ }
@Override
public void onTransitionEnd(Transition transition)
{
loadWallpaper(image);
}
@Override
public void onTransitionCancel(Transition transition)
{ }
@Override
public void onTransitionPause(Transition transition)
{ }
@Override
public void onTransitionResume(Transition transition)
{ }
};
getWindow().getEnterTransition().addListener(enterTransitionListener);
}
示例15: changeToConfirmScene
import android.transition.Transition; //导入依赖的package包/类
/**
* 共享元素
*/
private void changeToConfirmScene() {
final LayoutOrderConfirmationBinding confBinding = prepareConfirmationBinding();
final Scene scene = new Scene(binding.content,
((ViewGroup) confBinding.getRoot()));
scene.setEnterAction(onEnterConfirmScene(confBinding));
final Transition transition = TransitionInflater.from(getContext())
.inflateTransition(R.transition.transition_confirmation_view);
TransitionManager.go(scene, transition);
}