android - Scene. Slide transition under views -
look @ sample. have 2 scenes, start & end scenes. layout of start scene:
<?xml version="1.0" encoding="utf-8"?> <merge android:id="@+id/vgroot" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:parenttag="relativelayout" tools:ignore="hardcodedtext" > <button android:id="@+id/btn1" style="@style/widget.appcompat.button.borderless" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/cardview" android:text="button" android:layout_centerhorizontal="true" /> <button android:id="@+id/btngo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/btn1" android:text="@string/go" android:layout_centerhorizontal="true" /> <android.support.v7.widget.cardview android:id="@+id/cardview" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_margin="16dp" android:translationz="3dp" > <framelayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="#3829ab" android:padding="32dp" > <textview android:id="@+id/tvtext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="text title" android:textappearance="?android:textappearancemedium" android:textcolor="@android:color/white" /> </framelayout> </android.support.v7.widget.cardview> </merge>
there have btn1
sliding transition applied, cardview
, container
, change bounds , tvtext
body of cardview
.
and ending scene:
<?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:ignore="hardcodedtext" tools:parenttag="relativelayout" > <android.support.v7.widget.cardview android:id="@+id/cardview" android:layout_height="wrap_content" android:layout_width="match_parent" app:cardcornerradius="0dp" > <framelayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="8dp" android:background="#3829ab" android:orientation="vertical" > <textview android:id="@+id/tvtext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="text title" android:textappearance="?android:textappearancemedium" android:textcolor="@android:color/white" /> </framelayout> </android.support.v7.widget.cardview> </merge>
fragment code transition:
public class fragmentstarttransition extends fragment { @bindview(r.id.btngo) view btngo; @bindview(r.id.vgroot) viewgroup vgroot; private unbinder unbinder; @nullable @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { viewgroup view = (viewgroup) inflater.inflate(r.layout.fragment_start_transition, container, false); unbinder = bind(this, view); return view; } @override public void onviewcreated(view view, @nullable bundle savedinstancestate) { super.onviewcreated(view, savedinstancestate); btngo.setonclicklistener(btngo.setonclicklistener(v -> movenext()); } @override public void ondestroyview() { super.ondestroyview(); unbinder.unbind(); } private void movenext() { scene scene = scene.getsceneforlayout(vgroot, r.layout.scene_end, getcontext()); transitionmanager.go(scene, gettransition()); } private transition gettransition() { slide slide = new slide(gravity.top); slide.addtarget(r.id.btn1); changebounds changebounds = new changebounds(); changebounds.addtarget(r.id.cardview); changebounds.addtarget(r.id.container); changebounds.addtarget(r.id.tvtext); return new transitionset() .setordering(transitionset.ordering_together) .addtransition(slide) .addtransition(changebounds) .setduration(1500); } }
fragment_start_transition:
<relativelayout android:id="@+id/vgroot" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" tools:ignore="hardcodedtext" > <include layout="@layout/scene_start"/> </relativelayout>
result animation:
i want slide btn1 under cardview
, container
. can see cardview
placed @ end of root layout on button. in result animation slided on cardview
. can somehow control such z-axis relations between animated views?
tried cardview.bringtofront()
- doesn't help
there definetely should simple solution, can't find it.
need help, guys.
update: because framework draws slide transition on scene container view overlay, @ android.transition.visibility
class:
sceneroot.getoverlay().add(overlayview);
but question still opened.
Comments
Post a Comment