android - Transition with new Material Design Support lib -


i've tried make animation floating action button new activity said in page :

http://android-developers.blogspot.be/2014/10/implementing-material-design-in-your.html

in section: activity + fragment transitions

but don't see transition on screen. problem???

in original activity:

<android.support.design.widget.floatingactionbutton     android:id="@+id/fab"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="right|bottom"     android:src="@drawable/ic_add_white_48dp"     app:backgroundtint="@color/spg_rosa"     android:transitionname="@string/transition_add_pdv"     app:borderwidth="0dp"     app:elevation="8dp"     app:fabsize="normal" /> 

in destination activity, in mainlayout:

<linearlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:background="@color/spg_azul"     android:gravity="center_horizontal"     android:transitionname="@string/transition_add_pdv"     android:orientation="vertical"> 

and code:

fab = (floatingactionbutton) v.findviewbyid(r.id.fab);      fab.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             // added parameters intent() because giving me error             intent intent = new intent(getactivity(), addactivity.class);             string transitionname = getstring(r.string.transition_add_pdv);             activityoptionscompat options =                     activityoptionscompat.makescenetransitionanimation(getactivity(),                             fab,   // view starts transition                             transitionname    // transitionname of view we’re transitioning                     );             activitycompat.startactivity(getactivity(), intent, options.tobundle());         }     }); 

any idea?

to able use (activity activity, view sharedelement, string sharedelementname) must enable content transitions feature.

this requires feature_content_transitions enabled on calling activity cause exit transition. same must in called activity entering transition.

to this, set feature before setcontentview(int) in oncreate of both exiting , entering activities:

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     getwindow().requestfeature(window.feature_content_transitions);     setcontentview(r.layout.activity_main);     ... } 

note: feature api 21+. although, there work arounds libraries believe e.g. github.com/andkulikov/transitions-everywhere


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -