本文整理汇总了Java中android.transition.TransitionInflater类的典型用法代码示例。如果您正苦于以下问题:Java TransitionInflater类的具体用法?Java TransitionInflater怎么用?Java TransitionInflater使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TransitionInflater类属于android.transition包,在下文中一共展示了TransitionInflater类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initTransitions
import android.transition.TransitionInflater; //导入依赖的package包/类
@TargetApi(21) private void initTransitions() {
Window window = getActivity().getWindow();
window.setEnterTransition(
new ExplodeFadeEnterTransition(senderNameView, senderMailView, separatorLine));
window.setExitTransition(new ExcludedExplodeTransition());
window.setReenterTransition(new ExcludedExplodeTransition());
window.setReturnTransition(new ExcludedExplodeTransition());
TransitionSet textSizeSet = new TransitionSet();
textSizeSet.addTransition(
TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move));
TextSizeTransition textSizeTransition = new TextSizeTransition();
textSizeTransition.addTarget(R.id.subject);
textSizeTransition.addTarget(getString(R.string.shared_mail_subject));
textSizeSet.addTransition(textSizeTransition);
textSizeSet.setOrdering(TransitionSet.ORDERING_TOGETHER);
window.setSharedElementEnterTransition(textSizeSet);
getActivity().setEnterSharedElementCallback(
new TextSizeEnterSharedElementCallback(getActivity()));
}
示例2: onCreate
import android.transition.TransitionInflater; //导入依赖的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);
}
示例3: onCreate
import android.transition.TransitionInflater; //导入依赖的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);
}
示例4: navigateToAlbum
import android.transition.TransitionInflater; //导入依赖的package包/类
@TargetApi(21)
public static void navigateToAlbum(Activity context, long albumID, 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 = AlbumDetailFragment.newInstance(albumID, 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 = AlbumDetailFragment.newInstance(albumID, false, null);
}
transaction.hide(((AppCompatActivity) context).getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.add(R.id.fragment_container, fragment);
transaction.addToBackStack(null).commit();
}
示例5: navigateToArtist
import android.transition.TransitionInflater; //导入依赖的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();
}
示例6: onViewCreated
import android.transition.TransitionInflater; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
orderSelection = new OrderSelection();
selectedViewTransition = TransitionInflater.from(getContext())
.inflateTransition(R.transition.transition_selected_view);
binding.setProduct(getProduct());
binding.imgProduct.setImageDrawable(createProductImageDrawable(getProduct()));
binding.btnGo.setBackground(new ColorDrawable(ContextCompat.getColor(
getContext(), getProduct().color)));
initOrderStepOneView(binding.layoutStep1);
}
示例7: onConferenceSelected
import android.transition.TransitionInflater; //导入依赖的package包/类
@Override
public void onConferenceSelected(Conference con) {
mDisposables.add(mViewModel.getConference(con.getApiID())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(conference -> {
EventsFragment eventsFragment = EventsFragment.newInstance(conference.getApiID(),getNumColumns());
FragmentManager fm = getSupportFragmentManager();
Fragment oldFragment = fm.findFragmentById(R.id.fragment_container);
TransitionInflater transitionInflater = TransitionInflater.from(this);
oldFragment.setExitTransition(
transitionInflater.inflateTransition(android.R.transition.fade));
eventsFragment.setEnterTransition(
transitionInflater.inflateTransition(android.R.transition.slide_right));
Slide slideTransition = new Slide(Gravity.RIGHT);
eventsFragment.setEnterTransition(slideTransition);
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.fragment_container, eventsFragment);
ft.setReorderingAllowed(true);
ft.addToBackStack(null);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.commit();
}));
}
示例8: onViewCreated
import android.transition.TransitionInflater; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
orderSelection = new OrderSelection();
selectedViewTransition = TransitionInflater.from(getContext())
.inflateTransition(R.transition.transition_selected_view);
binding.setProduct(getProduct());
binding.imgProduct.setImageDrawable(createProductImageDrawable(getProduct()));
binding.btnGo.setBackground(new ColorDrawable(ContextCompat.getColor(
getContext(), getProduct().color)));
initOrderStepOneView(binding.layoutStep1);
}
示例9: onClick
import android.transition.TransitionInflater; //导入依赖的package包/类
@OnClick(R.id.square2)
public void onClick() {
FragmentSharedElementTransitionTarget targetFragment = new FragmentSharedElementTransitionTarget();
// FIXME: 08/02/2017 the shared element transitions to the next fragment below other views while it should be on top as in Activity transitions
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
TransitionSet transitionSet = new TransitionSet();
transitionSet.addTransition(new ChangeBounds());
transitionSet.setPathMotion(new ArcMotion());
targetFragment.setSharedElementEnterTransition(transitionSet);
targetFragment.setSharedElementReturnTransition(transitionSet);
targetFragment.setEnterTransition(TransitionInflater.from(getActivity()).inflateTransition(R.transition.slide_bottom));
targetFragment.setExitTransition(TransitionInflater.from(getActivity()).inflateTransition(R.transition.slide_top_and_fade));
setExitTransition(new Explode());
setReenterTransition(new Explode());
setAllowReturnTransitionOverlap(false);
}
getActivity().getSupportFragmentManager()
.beginTransaction()
.addSharedElement(square2, getString(R.string.custom_element_transition_name))
.replace(R.id.fragmentContainer, targetFragment)
.addToBackStack(null)
.commit();
}
示例10: createSlideAnimation
import android.transition.TransitionInflater; //导入依赖的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);
}
}
示例11: showFragment
import android.transition.TransitionInflater; //导入依赖的package包/类
@SuppressLint("NewApi")
public static void showFragment(FragmentActivity activity, Fragment firstFragment, Fragment secondFragment, @Nullable Pair<View, String>... transitionViews) {
boolean lollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
if(lollipop) {
firstFragment.setSharedElementReturnTransition(TransitionInflater.from(activity).inflateTransition(R.transition.change_image_transform));
secondFragment.setSharedElementEnterTransition(TransitionInflater.from(activity).inflateTransition(R.transition.change_image_transform));
}
FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction()
.replace(R.id.container, secondFragment)
.addToBackStack(null);
if(lollipop && transitionViews != null) {
for(Pair<View, String> tr : transitionViews) {
ft.addSharedElement(tr.first, tr.second);
}
}
ft.commit();
}
示例12: onClick
import android.transition.TransitionInflater; //导入依赖的package包/类
@Override
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
switch (v.getId()) {
case R.id.exlpode:
transition = TransitionInflater.from(this).inflateTransition(R.transition.explode);
break;
case R.id.slide:
transition = TransitionInflater.from(this).inflateTransition(R.transition.slide);
break;
default:
break;
}
//退出时使用
getWindow().setExitTransition(transition);
//第一次进入时使用
getWindow().setEnterTransition(transition);
//再次进入时使用
getWindow().setReenterTransition(transition);
Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(this).toBundle();
Intent intent = new Intent(mContext, TweenedAnimationActivity.class);
startActivity(intent,bundle);
}
}
示例13: displayDetails
import android.transition.TransitionInflater; //导入依赖的package包/类
@Override
public void displayDetails(AnnouncementItem announcementItem) {
FullAnnouncement announcement = announcementItem.getAnnouncement();
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
AnnouncementDetailsFragment announcementDetailsFragment = AnnouncementDetailsFragment.newInstance(announcement);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
TransitionInflater transitionInflater = null;
transitionInflater = TransitionInflater.from(getContext());
Transition details_enter = transitionInflater.inflateTransition(R.transition.details_enter);
Transition details_exit = transitionInflater.inflateTransition(R.transition.details_exit);
setSharedElementEnterTransition(details_enter);
setSharedElementReturnTransition(details_exit);
setExitTransition(new Fade());
announcementDetailsFragment.setSharedElementEnterTransition(details_enter);
announcementDetailsFragment.setSharedElementReturnTransition(details_exit);
ft.addSharedElement(announcementItem.getBackgroundView(), announcementItem.getBackgroundView().getTransitionName());
}
ft.replace(R.id.content_main, announcementDetailsFragment, "Announcement details transition");
ft.addToBackStack(null);
ft.commitAllowingStateLoss();
}
示例14: onOpenStoryDetail
import android.transition.TransitionInflater; //导入依赖的package包/类
@Override
public void onOpenStoryDetail(Story story, StoryAdapter.ViewHolder vh) {
Fragment storyDetailFragment = StoryDetailFragment.newInstance(story);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Transition changeTransform = TransitionInflater.from(this)
.inflateTransition(R.transition.transition_story);
mTopStoriesFragment.setExitTransition(new Fade());
storyDetailFragment.setEnterTransition(new Fade());
storyDetailFragment.setSharedElementEnterTransition(changeTransform);
storyDetailFragment.setSharedElementReturnTransition(changeTransform);
}
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, storyDetailFragment, TAG_STORY_DETAIL)
.addToBackStack(null)
.addSharedElement(vh.itemView, getString(R.string.story_transition_name, story.getId()))
.commit();
}
示例15: onCreate
import android.transition.TransitionInflater; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
pager.setAdapter(new AboutPagerAdapter(this));
pager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.spacing_normal));
pageIndicator.setViewPager(pager);
draggableFrame.addListener(
new ElasticDragDismissFrameLayout.SystemChromeFader(this) {
@Override
public void onDragDismissed() {
// if we drag dismiss downward then the default reversal of the enter
// transition would slide content upward which looks weird. So reverse it.
if (draggableFrame.getTranslationY() > 0) {
getWindow().setReturnTransition(
TransitionInflater.from(AboutActivity.this)
.inflateTransition(R.transition.about_return_downward));
}
finishAfterTransition();
}
});
}