我有三个布局文件。 共享航班物品用于简单航班物品和详细航班物品。
单击活动A中托管的片段中的简单航班项目时,我将启动活动B,该活动B托管保存详细信息片段的viewpager。我无法实现动画,更多的是,屏幕冻结,我必须再次单击两次以使屏幕响应。 所以我觉得新活动被调用,旧屏幕被绘制在新屏幕的顶部,但转换没有发生,因此只有旧屏幕可见。我的结论是对的吗?
编辑:我检查了新活动是否已创建。旧屏幕中的动画(在新活动中作为新屏幕上的叠加层绘制)不会隐藏以显示实际的新屏幕。
问题是因为共享项目在CollapsingToolbar中吗?
如何让它发挥作用?
开始新活动:
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent intent=new Intent(getActivity(), FlightDetailActivity.class);
intent.putExtras(args);
ActivityOptions options=ActivityOptions.makeCustomAnimation(getActivity(),R.id.shared,R.string.transition_flight);
ActivityCompat.startActivity(getActivity(),intent,options.toBundle());
}
共享航班项目:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:background="@android:color/transparent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:transitionName="@string/transition_flight">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="right">
<TextView
android:id="@+id/from_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textSize="22sp"
android:textColor="@color/textPrimary"/>
<!-- Other TextViews -->
</LinearLayout>
</LinearLayout>
简单飞行物品:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="@android:color/white"
android:orientation="vertical">
<include
android:id="@+id/shared"
layout="@layout/shared_flight_item" />
</LinearLayout>
详细航班视图:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="260dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingtoolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
app:layout_collapseMode="parallax">
<include
android:id="@+id/firstFlight"
layout="@layout/shared_flight_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f3f3f3"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- <android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardElevation="2dp"
card_view:cardUseCompatPadding="true"
>-->
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary"
android:gravity="center">
<include
android:id="@+id/secondFlight"
layout="@layout/shared_flight_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_margin="10dp">
<include
android:id="@+id/operator"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/flightNumber"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/pnr"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/duration"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/cancellation"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/inclusion"
layout="@layout/custom_detail_item_card" />
<include
android:id="@+id/details"
layout="@layout/custom_detail_item_card" />
</LinearLayout>
</LinearLayout>
<!--</android.support.v7.widget.CardView>-->
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:0)
我没有使用现有的动画,而是使用make自定义动画导致了这个问题。