本文整理汇总了Java中android.transition.Slide类的典型用法代码示例。如果您正苦于以下问题:Java Slide类的具体用法?Java Slide怎么用?Java Slide使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Slide类属于android.transition包,在下文中一共展示了Slide类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.transition.Slide; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
// getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
super.onCreate(savedInstanceState);
Slide slideIn = new Slide();
slideIn.setDuration(500);
//设置为进入
slideIn.setMode(Visibility.MODE_IN);
//设置从右边进入
slideIn.setSlideEdge(Gravity.RIGHT);
getWindow().setEnterTransition(new ChangeImageTransform().setDuration(3000));
// getWindow().setEnterTransition(new Explode().setDuration(2000));
// getWindow().setExitTransition(new Explode().setDuration(2000));
Slide slideReturn =new Slide();
slideReturn.setDuration(500);
slideReturn.setSlideEdge(Gravity.LEFT);
slideReturn.setMode(Visibility.MODE_OUT);
getWindow().setReturnTransition (slideReturn );
setContentView(R.layout.activity_img_transition);
mImageView = (ImageView) findViewById(R.id.img);
// Transition sharedElementEnterTransition = getWindow().getSharedElementEnterTransition();
}
示例2: onConferenceSelected
import android.transition.Slide; //导入依赖的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();
}));
}
示例3: onCreate
import android.transition.Slide; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Lollipop only :-(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
// Always set the exit transition because the "Next Episode" transition may be needed (we don't know yet)
getWindow().setExitTransition(new Slide(Gravity.LEFT));
// Set the enter animation only when asked (i.e. it is a "Next Episode" transition)
if (getIntent().getBooleanExtra(SLIDE_TRANSITION_EXTRA, false)) {
getWindow().setEnterTransition(new Slide(Gravity.RIGHT));
}
}
setContentView(R.layout.androidtv_details_activity);
}
示例4: onCreate
import android.transition.Slide; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_viewer);
ButterKnife.bind(this);
Slide slide = new Slide(Gravity.LEFT);
slide.addTarget(R.id.tv_text);
getWindow().setEnterTransition(slide);
// Explode explode = new Explode();
// explode.addTarget(R.id.tv_text);
// getWindow().setEnterTransition(explode);
ImageView imageView = (ImageView) findViewById(R.id.image);
imageView.setImageResource(getIntent().getIntExtra("resId", R.mipmap.pic_1));
// ViewCompat.setTransitionName(imageView, "image");
}
示例5: constructTransitions
import android.transition.Slide; //导入依赖的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;
}
示例6: createSlideAnimation
import android.transition.Slide; //导入依赖的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);
}
}
示例7: addNextFragment
import android.transition.Slide; //导入依赖的package包/类
private void addNextFragment(Sample sample, ImageView squareBlue, boolean overlap) {
SharedElementFragment2 sharedElementFragment2 = SharedElementFragment2.newInstance(sample);
Slide slideTransition = new Slide(Gravity.RIGHT);
slideTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium));
ChangeBounds changeBoundsTransition = new ChangeBounds();
changeBoundsTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium));
sharedElementFragment2.setEnterTransition(slideTransition);
sharedElementFragment2.setAllowEnterTransitionOverlap(overlap);
sharedElementFragment2.setAllowReturnTransitionOverlap(overlap);
sharedElementFragment2.setSharedElementEnterTransition(changeBoundsTransition);
getFragmentManager().beginTransaction()
.replace(R.id.sample2_content, sharedElementFragment2)
.addToBackStack(null)
.addSharedElement(squareBlue, getString(R.string.square_blue_name))
.commit();
}
示例8: openPlaylist
import android.transition.Slide; //导入依赖的package包/类
@Override
public void openPlaylist(String name) {
// Create fragment and give it an argument for the selected article
PlaylistTracksFragment newFragment = new PlaylistTracksFragment();
Bundle args = new Bundle();
args.putString(PlaylistTracksFragment.EXTRA_PLAYLIST_NAME, name);
newFragment.setArguments(args);
android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
newFragment.setEnterTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.START, getResources().getConfiguration().getLayoutDirection())));
newFragment.setExitTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.END, getResources().getConfiguration().getLayoutDirection())));
// Replace whatever is in the fragment_container view with this
// fragment,
// and add the transaction to the back stack so the user can navigate
// back
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack("PlaylistTracksFragment");
// Commit the transaction
transaction.commit();
}
示例9: openPath
import android.transition.Slide; //导入依赖的package包/类
@Override
public void openPath(String path) {
// Create fragment and give it an argument for the selected directory
FilesFragment newFragment = new FilesFragment();
Bundle args = new Bundle();
args.putString(FilesFragment.EXTRA_FILENAME, path);
newFragment.setArguments(args);
FragmentManager fragmentManager = getSupportFragmentManager();
android.support.v4.app.FragmentTransaction transaction = fragmentManager.beginTransaction();
newFragment.setEnterTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.START, getResources().getConfiguration().getLayoutDirection())));
newFragment.setExitTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.END, getResources().getConfiguration().getLayoutDirection())));
transaction.addToBackStack("FilesFragment" + path);
transaction.replace(R.id.fragment_container, newFragment);
// Commit the transaction
transaction.commit();
}
示例10: onCreate
import android.transition.Slide; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_detail);
postponeEnterTransition();
TransitionSet transitions = new TransitionSet();
Slide slide = new Slide(Gravity.BOTTOM);
slide.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.interpolator.linear_out_slow_in));
slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
transitions.addTransition(slide);
transitions.addTransition(new Fade());
getWindow().setEnterTransition(transitions);
Intent intent = getIntent();
sharedElementCallback = new DetailSharedElementEnterCallback(intent);
setEnterSharedElementCallback(sharedElementCallback);
initialItem = intent.getIntExtra(IntentUtil.SELECTED_ITEM_POSITION, 0);
setUpViewPager(intent.<Photo>getParcelableArrayListExtra(IntentUtil.PHOTO));
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(navigationOnClickListener);
super.onCreate(savedInstanceState);
}
示例11: onStart
import android.transition.Slide; //导入依赖的package包/类
@Override
protected void onStart() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
Slide slide = new Slide(Gravity.BOTTOM);
if(isFirstLaunch) {
fab.hide();
isFirstLaunch = false;
}
slide.addTarget(R.id.description_card);
slide.addTarget(R.id.venue_time_card);
slide.addTarget(R.id.registration_card);
slide.addTarget(R.id.prizes_card);
slide.addTarget(R.id.organizers_card);
slide.setInterpolator(new LinearOutSlowInInterpolator());
getWindow().setEnterTransition(slide);
getWindow().setExitTransition(slide);
getWindow().setReenterTransition(slide);
setupEnterAnimation();
}
super.onStart();
}
示例12: setupSlideTransition
import android.transition.Slide; //导入依赖的package包/类
private void setupSlideTransition() {
Slide slideEnter = new Slide();
slideEnter.setSlideEdge(Gravity.LEFT);
slideEnter.setDuration(500);
slideEnter.setStartDelay(250);
slideEnter.excludeTarget(android.R.id.navigationBarBackground, true);
slideEnter.excludeTarget(android.R.id.statusBarBackground, true);
getWindow().setEnterTransition(slideEnter);
Slide slideOut = new Slide();
slideOut.setSlideEdge(Gravity.RIGHT);
slideOut.setDuration(500);
slideOut.setStartDelay(0);
slideOut.excludeTarget(android.R.id.navigationBarBackground, true);
slideOut.excludeTarget(android.R.id.statusBarBackground, true);
getWindow().setExitTransition(slideOut);
}
示例13: setupSlideTransition
import android.transition.Slide; //导入依赖的package包/类
private void setupSlideTransition() {
Slide slideEnter = new Slide();
slideEnter.addTarget(R.id.text_card);
slideEnter.setDuration(1000);
slideEnter.setStartDelay(500);
slideEnter.setSlideEdge(Gravity.RIGHT);
slideEnter.excludeTarget(android.R.id.navigationBarBackground, true);
slideEnter.excludeTarget(android.R.id.statusBarBackground, true);
getWindow().setEnterTransition(slideEnter);
// Tips: Cann't set same Transition object to more than one Transition callbacks.
// getWindow().setReenterTransition(slideEnter);
Slide slideOut = new Slide();
slideOut.addTarget(R.id.text_card);
slideOut.setDuration(500);
slideOut.setSlideEdge(Gravity.RIGHT);
slideOut.excludeTarget(android.R.id.navigationBarBackground, true);
slideOut.excludeTarget(android.R.id.statusBarBackground, true);
getWindow().setExitTransition(slideOut);
}
示例14: onClickBegin
import android.transition.Slide; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@OnClick(R.id.next)
public void onClickBegin(View view) {
//set behavior for this fragment
setExitTransition(new Slide(Gravity.START));
setReenterTransition(new Slide(Gravity.TOP));
WelcomeFragmentStep2 fragment = new WelcomeFragmentStep2();
//set behavior for new fragment transitions
fragment.setEnterTransition(new Fade());
fragment.setSharedElementEnterTransition(getNextButtonTransition());
getActivity().getFragmentManager().beginTransaction()
.replace(R.id.root, fragment)
.addSharedElement(next, "next")
.addToBackStack(null)
.commit();
}
示例15: click
import android.transition.Slide; //导入依赖的package包/类
public void click(View view) {
/*
* Slide: this transition tracks changes to the visibility of target views
* in the start and end scenes and moves views in or out
* from one of the edges of the scene.
*/
Slide slide = new Slide();
// Change the edge that Views appear and disappear from.
slide.setSlideEdge(Gravity.TOP);
ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
/*
* beginDelayedTransition: Convenience method to animate to a new scene
* defined by all changes within the given scene root
* between calling this method and the next rendering frame.
*/
TransitionManager.beginDelayedTransition(root, slide);
imageView.setVisibility(View.INVISIBLE);
}