0
我有三個佈局文件。 共享航班物品用於簡單航班物品和詳細航班物品。無法使用動畫啓動Android活動
單擊活動A中託管的片段中的簡單飛行項目時,我將啓動託管包含詳細片段的viewpager的活動B.我無法實現動畫,更多的是,屏幕凍結,我必須點擊兩次以使屏幕響應。 所以我覺得新的活動被調用,舊屏幕在新屏幕的頂部繪製,但過渡不會發生,因此舊屏幕只能看到。我的結論是對的嗎?
編輯:我檢查了新的活動正在創建。來自舊屏幕的動畫(在新活動中作爲新屏幕上的覆蓋物繪製)不隱藏以揭示實際的新屏幕。
問題是因爲共享項目在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>