片段之间的过渡动​​画

时间:2018-05-18 15:44:47

标签: android android-fragments android-animation

我有两个片段(A,B),我可以互换;我想要实现的是每次交换它们时它们之间的上下滑动动画。

我尝试使用这样的两个对象动画师:



com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Error finding JNDI name (THENAME)---- Error code:-2147467259 Error code name:failed
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(SourceFile:237)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:147)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:128)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:111)
    at gac.read.Reader.main(Reader.java:49)
Caused by: com.crystaldecisions.reports.common.JndiNotFoundException: Error finding JNDI name (THENAME)
    at com.crystaldecisions.reports.queryengine.Connection.a(SourceFile:1871)
    at com.crystaldecisions.reports.queryengine.Connection.br(SourceFile:1815)
    at com.crystaldecisions.reports.queryengine.Connection.bs(SourceFile:505)
    at com.crystaldecisions.reports.queryengine.Connection.t4(SourceFile:3020)
    at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.a(SourceFile:697)
    at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.for(SourceFile:707)
    at com.crystaldecisions.reports.reportdefinition.ReportHelper.a(SourceFile:198)
    at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.long(SourceFile:958)
    at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.a(SourceFile:636)
    at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.int(SourceFile:673)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.do(SourceFile:1943)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(SourceFile:660)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(SourceFile:166)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.a(SourceFile:528)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.call(SourceFile:526)
    at com.crystaldecisions.reports.common.ThreadGuard.syncExecute(SourceFile:102)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.for(SourceFile:524)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.int(SourceFile:423)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(SourceFile:351)
    at com.businessobjects.sdk.erom.jrc.a.a(SourceFile:54)
    at com.businessobjects.sdk.erom.jrc.a.execute(SourceFile:67)
    at com.crystaldecisions.proxy.remoteagent.RemoteAgent$a.execute(SourceFile:716)
    at com.crystaldecisions.proxy.remoteagent.CommunicationChannel.a(SourceFile:125)
    at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(SourceFile:537)
    at com.crystaldecisions.sdk.occa.report.application.ds.a(SourceFile:186)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(SourceFile:1558)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(SourceFile:337)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(SourceFile:223)
    ... 4 more
Caused by: com.businessobjects.reports.jdbinterface.common.DBException: Error finding JNDI name (THENAME)
    at com.crystaldecisions.reports.queryengine.driverImpl.jdbc.JDBCConnection.Open(Unknown Source)
    at com.crystaldecisions.reports.queryengine.JDBConnectionWrapper.Open(SourceFile:123)
    at com.crystaldecisions.reports.queryengine.Connection.br(SourceFile:1786)
    ... 30 more

但它没有奏效,因为这两个片段是重叠的。 那我该怎么做动画呢?

片段A:

com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Error finding JNDI name (THENAME)---- Error code:-2147467259 Error code name:failed
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(SourceFile:237)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:147)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:128)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(SourceFile:111)
    at gac.read.Reader.main(Reader.java:49)
Caused by: com.crystaldecisions.reports.common.JndiNotFoundException: Error finding JNDI name (THENAME)
    at com.crystaldecisions.reports.queryengine.Connection.a(SourceFile:1871)
    at com.crystaldecisions.reports.queryengine.Connection.br(SourceFile:1815)
    at com.crystaldecisions.reports.queryengine.Connection.bs(SourceFile:505)
    at com.crystaldecisions.reports.queryengine.Connection.t4(SourceFile:3020)
    at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.a(SourceFile:697)
    at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.for(SourceFile:707)
    at com.crystaldecisions.reports.reportdefinition.ReportHelper.a(SourceFile:198)
    at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.long(SourceFile:958)
    at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.a(SourceFile:636)
    at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.int(SourceFile:673)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.do(SourceFile:1943)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(SourceFile:660)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(SourceFile:166)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.a(SourceFile:528)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.call(SourceFile:526)
    at com.crystaldecisions.reports.common.ThreadGuard.syncExecute(SourceFile:102)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.for(SourceFile:524)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.int(SourceFile:423)
    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(SourceFile:351)
    at com.businessobjects.sdk.erom.jrc.a.a(SourceFile:54)
    at com.businessobjects.sdk.erom.jrc.a.execute(SourceFile:67)
    at com.crystaldecisions.proxy.remoteagent.RemoteAgent$a.execute(SourceFile:716)
    at com.crystaldecisions.proxy.remoteagent.CommunicationChannel.a(SourceFile:125)
    at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(SourceFile:537)
    at com.crystaldecisions.sdk.occa.report.application.ds.a(SourceFile:186)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(SourceFile:1558)
    at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(SourceFile:337)
    at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(SourceFile:223)
    ... 4 more
Caused by: com.businessobjects.reports.jdbinterface.common.DBException: Error finding JNDI name (THENAME)
    at com.crystaldecisions.reports.queryengine.driverImpl.jdbc.JDBCConnection.Open(Unknown Source)
    at com.crystaldecisions.reports.queryengine.JDBConnectionWrapper.Open(SourceFile:123)
    at com.crystaldecisions.reports.queryengine.Connection.br(SourceFile:1786)
    ... 30 more

片段B:

2 个答案:

答案 0 :(得分:2)

Google发布了新的Navigation UI

所以,现在我们可以从your_named_navigation.xml资源(main> res> navigation> your_named_navigation.xml)执行相同的片段转换,

这是我实施的代码段:

<?xml version="1.0" encoding="utf-8"?>
<navigation 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"
    app:startDestination="@+id/first_fragment">

    <fragment
        android:id="@+id/first_fragment"
        android:name="com.yourpackage.FirstFragment"
        android:label="@string/title_first"
        tools:layout="@layout/fragment_first">

        <action
            android:id="@+id/second_fragment_action"
            app:destination="@id/second_fragment"
            app:enterAnim="@anim/slide_in_right"
            app:exitAnim="@anim/slide_out_left"
            app:popEnterAnim="@anim/slide_in_left"
            app:popExitAnim="@anim/slide_out_right" />

    </fragment>

    <fragment
        android:id="@+id/second_fragment"
        android:name="com.yourpackage.SecondFragment"
        android:label="@string/title_second"
        tools:layout="@layout/fragment_second">

        <action ...next fragment/>

    </fragment>

</navigation>

它还有助于处理后退按钮和向上按钮的点击,

所以,在我们的proyect中实现了NavigationUi后,我们可以从我们的firstFragment实例调用Navigation.findNavController方法

myButton.setOnClickListener(View.OnClickListener {
    //This opens our second fragment creating a stack of fragments
    Navigation.findNavController(it).navigate(R.id.second_fragment_action)
})

下一个Google's Codelab帮助了我,也许可以帮助你,问候

答案 1 :(得分:1)

动画/ slide_in_left.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <objectAnimator
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="500"
        android:propertyName="x"
        android:valueFrom="1000"
        android:valueTo="0"
        android:valueType="floatType" />

</set>

动画/ slide_out_right.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <objectAnimator
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="500"
        android:propertyName="x"
        android:valueFrom="0"
        android:valueTo="-1000"
        android:valueType="floatType" />

</set>

Class Subcategory

 public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            // return super.onCreateView(inflater, container, savedInstanceState);

            View view = (ViewGroup) inflater.inflate(R.layout.product_frame, null);
            getFragmentManager().beginTransaction()
                    .replace(R.id.sub_header, new Sub_Header()).commit();
            getFragmentManager()
                    .beginTransaction()
                    .setCustomAnimations(R.animator.slide_in_left,
                            R.animator.slide_out_right, 0, 0)
                    .replace(R.id.product_frame, new Sub_Catagory_Grid()).commit();

            view.getWidth();
            return view;

        }

一些链接

Fragment transaction animation: slide in and slide out

How to apply a fade-in/fade-out animation when replacing a fragment