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


Java TransitionInflater類代碼示例

本文整理匯總了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()));
  }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:DetailsFragment.java

示例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);
    }
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:19,代碼來源:WindowTransitionsSecondActivity.java

示例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);
    }
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:21,代碼來源:WindowTransitionsActivity.java

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

}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:22,代碼來源:NavigationUtils.java

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

}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:22,代碼來源:NavigationUtils.java

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

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

示例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);
}
 
開發者ID:saulmm,項目名稱:From-design-to-Android-part1,代碼行數:18,代碼來源:OrderDialogFragment.java

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

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

示例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();
}
 
開發者ID:andryr,項目名稱:Harmony-Music-Player,代碼行數:21,代碼來源:NavigationUtils.java

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

}
 
開發者ID:REBOOTERS,項目名稱:AndroidAnimationExercise,代碼行數:27,代碼來源:SwitchAnimActivity.java

示例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();
}
 
開發者ID:shymmq,項目名稱:librus-client,代碼行數:27,代碼來源:AnnouncementsFragment.java

示例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();
}
 
開發者ID:setiawanp,項目名稱:sunny-reader,代碼行數:19,代碼來源:MainActivity.java

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


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