मैं एक साझा तत्व संक्रमण को कार्यान्वित करने की कोशिश कर रहा हूं जब एक स्क्रीन से 2 ImageViews
अगली स्क्रीन पर जाएं। छवियों में से एक के पास स्क्रीन पर centerCrop
का स्केल टाइप है। जिस समस्या का सामना करना पड़ रहा है वह यह है कि जब संक्रमण शुरू होता है तो छवि अगली स्क्रीन पर एनिमेट करने से पहले ही इसका मूल आकार (फसल से पहले) जा रही है। जब यह अगली स्क्रीन तक पहुंच जाए तो यह इसे अपने मूल आकार के साथ पहुंचता है और केवल तभी यह लक्ष्य छवि दृश्य में फंस जाता है।स्केल टाइप टाइप के साथ साझा तत्व क्रॉप संक्रमण अजीब है:
पूरा अनुभव चिकनी और आंखों के लिए वास्तव में अजीब नहीं है। कोड मैं का उपयोग करें:
public void animateIntent(View view, ArticleCoverData articleCoverData) {
Intent intent = new Intent(mActivity, ReaderActivity.class);
intent.putExtra(Constants.ARTICLE_DATA, articleCoverData);
// The view animation will start from
View coverStartView = view.findViewById(R.id.coverImage);
View coverDiagonalDecoratorStartView = view.findViewById(R.id.diagonal_image_decorator);
Pair<View, String> pair1 = Pair.create(coverStartView, mActivity.getString(R.string.transition_timeline_cover_image_to_reader_name));
Pair<View, String> pair2 = Pair.create(coverDiagonalDecoratorStartView, mActivity.getString(R.string.transition_timeline_cover_image_diagonal_decorator_to_reader_name));
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(mActivity, pair1, pair2);
ActivityCompat.startActivity(mActivity, intent, options.toBundle());
}
छवि वेब निम्न कोड के साथ Glide
का उपयोग करने से भरी हुई है:
Glide.with(mActivity).load(articleCoverData.mImageUrl).skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.SOURCE).dontTransform().into(holder.coverImage);
प्राप्त ओर छवि के रूप में भरी हुई है पर इस प्रकार है:
Glide.with(mContext).load(mData.mImageUrl).skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(mCoverImageView);
शैली में मैंने परिभाषित किया:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Add this line -->
<item name="android:windowContentTransitions">true</item>
<!-- This is the color of the Status bar -->
<item name="colorPrimaryDark">@color/transparent</item>
<!-- specify shared element transitions -->
<item name="android:windowSharedElementEnterTransition">
@transition/change_image_transform</item>
<item name="android:windowSharedElementExitTransition">
@transition/change_image_transform</item>
</style>
जब change_image_transform
है:
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<changeImageTransform/>
</transitionSet>
संपादित करें: के लिए संक्रमण को बदलने की कोशिश की:
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<changeBounds/>
<changeTransform/>
<changeImageTransform/>
</transitionSet>
या
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<changeBounds/>
<changeImageTransform/>
</transitionSet>
लेकिन परिणाम एक ही है।
प्रश्न यह है: क्या मुझे यहां कुछ याद आ रही है, क्या मुझे इस अनुभव को परेशान करने के लिए कुछ और करने की ज़रूरत है? या यह एक एंड्रॉइड बग है?
अग्रिम धन्यवाद।
यह कुंजी थी "छविव्यू स्केल टाइप पैरामीटर का उपयोग करके अपने स्केल प्रकार को लागू करना और पिकासो फसल या ग्लाइड फसल का उपयोग नहीं करना महत्वपूर्ण बात है।" धन्यवाद – Lancelot