2016-03-24 1 views
0

translateアニメーションを使用して、フラグメントを下から上にスライドします。このアニメーションでは、ToolbarまたはActionBarが背面に送信され、アニメーションに何らかの不具合があるように見えます(アニメーションFragmentToolbar)。Android - フラグメントアニメーションの前にActionBar/Toolbarを保存する

Toolbarが常にアニメーションの前に表示されていることを確認する方法はありますか?私は:zAdjustmentbottomに設定しようとしましたが、それは何も変わりませんでした。

ここではアニメーションの1つがあります。他は、:fromYDelta:toYDeltaのバリエーションです。

<set> 
    <translate 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:fromYDelta="-100%" 
     android:toYDelta="0" 
     android:interpolator="@android:anim/decelerate_interpolator" 
     android:duration="1000"/> 
</set> 

FragmentTransaction

getSupportFragmentManager().beginTransaction() 
     .setCustomAnimations(R.anim.slide_in_bottom, R.anim.slide_out_top, R.anim.slide_in_top, R.anim.slide_out_bottom) 
     .replace(R.id.master_container, getManageFragment()) 
     .addToBackStack(null) 
     .commit(); 

これは私のactivity_main.xml

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/main_drawer" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <!-- The main content view --> 
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/master_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <include layout="@layout/navigation_toolbar" /> 

    </LinearLayout> 

    <include layout="@layout/navigation_view" /> 

</android.support.v4.widget.DrawerLayout> 

され、その後、このレイアウトはmaster_container

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/global_background" 
    app:layout_behavior="com.cohenadair.anglerslog.views.FloatingButtonBehavior"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/main_recycler_view" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" 
     android:paddingTop="@dimen/margin_half" 
     android:paddingBottom="@dimen/margin_half" 
     android:clipToPadding="false"/> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/new_button" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_margin="@dimen/margin_default" 
     android:src="@drawable/ic_add" 
     app:elevation="0dp" 
     app:layout_anchor="@id/main_recycler_view" 
     app:layout_anchorGravity="bottom|right|end" 
     app:layout_behavior="com.cohenadair.anglerslog.utilities.ScrollingFabBehavior"/> 

</android.support.design.widget.CoordinatorLayout> 

感謝ヨーヨーに追加されますu。

EDIT:Thisも同様の問題のようです。

+0

? 'アクティビティ'または 'フラグメント'の中で? –

+0

これは 'Activity'に設定されています – cohenadair

+0

' activity'の場合、 'FrameLayout'の遷移は' toolbar'に影響しません。 –

答えて

0

ToolbarActivityに設定すると、FrameLayoutのトランジションはツールバーに影響しません。

getSupportFragmentManager().beginTransaction() 
        .setCustomAnimations(R.anim.enter_from_top, R.anim.exit_to_bottom, R.anim.enter_from_bottom, R.anim.exit_to_top) 
        .replace(R.id.fragment_container, fragment, fragment.getClass().getSimpleName()) 
        .commitAllowingStateLoss(); 

enter_from_bottom.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shareInterpolator="false"> 
    <translate 
     android:fromXDelta="0%" android:toXDelta="0%" 
     android:fromYDelta="100%" android:toYDelta="0%" 
     android:duration="700" /> 
</set> 

enter_from_top.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shareInterpolator="false"> 
    <translate 
     android:fromXDelta="0%" android:toXDelta="0%" 
     android:fromYDelta="-100%" android:toYDelta="0%" 
     android:duration="700"/> 
</set> 

exit_to_bottom:私はこの&それがアニメーションのため

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawerLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:openDrawer="start"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:contentInsetStartWithNavigation="0dp" 
      app:layout_collapseMode="pin" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      app:contentInsetLeft="0dp" 
      app:contentInsetStart="0dp" 
      android:title="@string/app_name" 
      android:background="@color/colorPrimaryDark" 
      app:contentInsetStartWithNavigation="0dp"/> 

     <FrameLayout 
      android:id="@+id/fragment_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/toolbar"/> 
    </RelativeLayout> 
    <include layout="@layout/navigation_drawer_layout"/> 
</android.support.v4.widget.DrawerLayout> 

を働いているように試してみました.xmlの

<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shareInterpolator="false"> 
    <translate 
     android:fromXDelta="0%" android:toXDelta="0%" 
     android:fromYDelta="0%" android:toYDelta="100%" 
     android:duration="700" /> 
</set> 

exit_to_top.xmlあなたは `toolbar`を設定している

<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shareInterpolator="false"> 
    <translate 
     android:fromXDelta="0%" android:toXDelta="0%" 
     android:fromYDelta="0%" android:toYDelta="-100%" 
     android:duration="700"/> 
</set> 
関連する問題