2016-07-06 15 views
2

簡短的問題:動畫效果片段導致其他以「跳」

在使用上FragmentTransactions動畫,我怎麼能動畫與動漫其他意見?

長的問題:

嗨,

我是新來的片段等等,我想它們的動畫保險業監督單一的活動,所以我創建了下面的XML文件的活動:

<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> 

然後我definded的RES /動畫文件,我想使用的動畫:

fade_in_from_t op.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> 

詳細地: 下部片段C通常會列出幾個項目。我根據切換按鈕搜索的內容來更改片段。那沒問題。在加載數據

首先顯示裝載片段:當在特定的一個ListEntry的headerFragment用戶點擊將在動畫中填充有附加的數據並顯示使用褪色等

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(); 

後數據加載顯示在一個新的片段的數據代替加載片段

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); 

問題IST該headerfragment是衰落和從頂部或底部方向滑動,而該片段保持列表視圖IST「跳躍」到的下Y Ť他甚至在那裏之前就是頭片碎片。我如何動畫下面的片段與標題片段一起滑動以創建流暢的用戶體驗?

對不起,長期以來的問題。如果搜索了3天,並沒有發現任何幫助我的問題。

回答

0

我幾乎被添加到的LinearLayout(run_select_fragment_container)

android:animateLayoutChanges="true" 

而且在活動的OnCreate我已經這樣做了

LinearLayout mainLayout = (LinearLayout) findViewById(R.id.run_select_fragment_container); 
LayoutTransition layoutTransition = mainLayout.getLayoutTransition(); 
layoutTransition.enableTransitionType(LayoutTransition.CHANGING); 
解決它
相關問題