本文整理匯總了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();
}
});
}