简体   繁体   中英

Android Slide Animation within layout

How can I do this animation in my activity?

when you click a button in the layout, it will slide like this(can't post too many links and picture yet

I already tried doing tabbed but its not the one i'm looking for. its my first time doing, I only know how to have slide animation between activity

Thanks in Advance

EDIT*

I want to know how to get this effect

http://i.stack.imgur.com/nJtFw.jpg

You can use a fragment for the central layout and then use Fragment animations like this

FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right);
DetailsFragment newFragment = DetailsFragment.newInstance();
ft.replace(R.id.details_fragment_container, newFragment, "detailFragment");
ft.commit();

Where the xml file for animation could look like.

<?xml version="1.0" encoding="utf-8"?>
<set>
  <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="x" 
android:valueType="floatType"
android:valueFrom="-1280"
android:valueTo="0" 
android:duration="500"/>
</set>

There are many other animations you can apply, you can find more resources here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM