android - Animating Fragment causes other view to "jump" -


short question:

when using animation on fragmenttransactions, how can animate other views animation?

long question:

hi,

i new fragments , on, , trying animate them single activity created following xml file activity:

<linearlayout     android:id="@+id/run_select_fragment_container"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:keepscreenon="true"     android:orientation="vertical">       <framelayout         android:id="@+id/activity_run_search_fragmentheaderplaceholder"         android:layout_width="match_parent"         android:layout_height="wrap_content" />      <framelayout         android:id="@+id/activity_run_search_fragmentplaceholder"         android:layout_width="match_parent"         android:layout_height="0dp"         android:layout_weight="1"/>  </linearlayout> 

then definded res/anim files want use animation:

fade_in_from_top.xml

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"     android:shareinterpolator="false">      <alpha android:fromalpha="0.0" android:toalpha="1.0"         android:duration="@android:integer/config_longanimtime" />      <translate         android:fromxdelta="0%" android:toxdelta="0%"         android:fromydelta="-100%" android:toydelta="0%"         android:duration="1000" /> </set> 

fade_in_from_bottom.xml

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"     android:shareinterpolator="false">      <alpha android:fromalpha="0.0" android:toalpha="1.0"         android:duration="@android:integer/config_longanimtime" />      <translate         android:fromxdelta="0%" android:toxdelta="0%"         android:fromydelta="100%" android:toydelta="0%"         android:duration="1000"/> </set> 

fade_out_to_bottom.xml

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"     android:shareinterpolator="false">     <alpha         android:duration="@android:integer/config_longanimtime"         android:fromalpha="1.0"         android:toalpha="0.0" />      <translate         android:duration="700"         android:fromxdelta="0%"         android:fromydelta="0%"         android:toxdelta="0%"         android:toydelta="100%" /> </set> 

fade_out_to_top.xml

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"     android:shareinterpolator="false">      <alpha         android:duration="@android:integer/config_longanimtime"         android:fromalpha="1.0"         android:toalpha="0.0" />      <translate         android:duration="700"         android:fromxdelta="0%"         android:fromydelta="0%"         android:toxdelta="0%"         android:toydelta="-100%" /> </set> 

in detail: lower fragment contains listview several items. change fragments based on search toggle button. thats no problem. when user clicks on specific listentry headerfragment filled additional data , displayed fade in animation like:

first show loading fragment while loading data:

final rsbasefragment headerfragment = (rsbasefragment) getsupportfragmentmanager().findfragmentbyid(r.id.activity_run_search_fragmentheaderplaceholder);  fragmenttransaction ft = getsupportfragmentmanager().begintransaction(); loadingfragment fragment = new loadingfragment();  if (headerfragment != null) {     ft.setcustomanimations(r.anim.fade_in_from_bottom, r.anim.fade_out_to_top, r.anim.fade_in_from_top, r.anim.fade_out_to_bottom);     ft.replace(r.id.activity_run_search_fragmentheaderplaceholder, fragment, header_fragment_tag); } else {     ft.setcustomanimations(r.anim.fade_in_from_top, r.anim.fade_out_to_bottom, r.anim.fade_in_from_bottom, r.anim.fade_out_to_top);     ft.add(r.id.activity_run_search_fragmentheaderplaceholder, fragment, header_fragment_tag); } ft.commit(); 

after data loaded show data in new fragment replacing loading fragment

headerfragment fragment = new headerfragment(); ft.setcustomanimations(r.anim.fade_in_from_top, r.anim.fade_out_to_bottom, r.anim.fade_in_from_bottom, r.anim.fade_out_to_top); ft.replace(r.id.activity_run_search_fragmentheaderplaceholder, fragment, header_fragment_tag); 

the problem ist headerfragment fading , sliding in top or bottom direction, while fragment holding listview ist "jumping" bottom y of headerfragment before it's there. how can animate lower fragment slide header fragment create smooth user experience?

sorry long question. if searched 3 days , did not found helping problem.

i solved adding linearlayout (run_select_fragment_container)

android:animatelayoutchanges="true" 

and in oncreate of activity have done this

linearlayout mainlayout = (linearlayout) findviewbyid(r.id.run_select_fragment_container); layouttransition layouttransition = mainlayout.getlayouttransition(); layouttransition.enabletransitiontype(layouttransition.changing); 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -