私は主なアクティビティでImageViewを表示しているカードビューのグリッドビューを持っています。私は、共有要素をイメージから詳細アクティビティに移行しようとしています。ここで共有要素グリッドビューからの遷移が正しい位置から開始されない
はMainActivity
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<GridView
android:id="@+id/showGrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="2"
android:layout_margin="16dp"
android:verticalSpacing="16dp"/>
</android.support.v4.widget.NestedScrollView>
から関連するセクションは、アイテム
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/showCard"
android:layout_width="180dp"
android:layout_height="180dp"
android:layout_marginBottom="16dp"
android:background="@android:color/white"
android:elevation="8dp"
android:foreground="?selectableItemBackground"
android:orientation="vertical">
<ImageView
android:id="@+id/showLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/rth"
android:transitionName="logoImage" />
そしてDetailsActivity
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="400dp">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/rth"
android:transitionName="logoImage"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7" />
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
彼のためのXMLのxmlですMainActivityのjavaです。
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent intent = new Intent(MainActivity.this, FeedActivity.class);
Show show = (Show) adapterView.getItemAtPosition(i);
intent.putExtra("selectedShow", show);
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this, (View)findViewById(R.id.showLogo), "logoImage");
startActivity(intent, options.toBundle());
}
}
遷移効果が発生し、正しいイメージが表示されます。ただし、遷移は常にグリッドビューの最初の項目から開始します。出口の遷移は、たとえそれが別の位置から来たとしても、detailsActivityからの画像をグリッドビューの最初の項目に戻して表示します。
ユーザーが選択したアイテムの開始と終了を切り替えるにはどうすればよいですか?ありがとう!