gpt4 book ai didi

Android共享元素过渡,起始位置错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:11:19 25 4
gpt4 key购买 nike

我的布局如下图所示

enter image description here

其中橙色框架是 HostFragment 是这样构建的:

<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/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<android.support.design.widget.AppBarLayout
android:id="@id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<android.support.v7.widget.Toolbar
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleMarginStart="68dp"
/>

<de.halfbit.audiopie.ui.common.views.SlidingTabs
android:id="@id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:slidingTabsIndicatorColor="@color/accent"
/>

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
android:id="@id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>

蓝色框架是一个子ItemsFragment,里面有一个RecyclerView

当我点击 RecyclerView 中的图 block 时,我将 HostFragment 替换为另一个 ContentFragment fragment ,该 fragment 假定共享点击的图像。我通过应用共享元素转换来实现,如下所示:

FragmentManager fm = getChildFragmentManager();
Fragment fragment = ContentFragment.newInstance();

AutoTransition autoTransition = new AutoTransition();
autoTransition.setDuration(3000);
fragment.setSharedElementEnterTransition(autoTransition);

fm.beginTransaction()
.replace(R.id.library, fragment)
.addSharedElement(view, "cover")
.commit();

除了一件事它工作正常:当动画在 ContentFragment 中开始时,封面图 block 的初始位置是错误的 (see this screen cast video) - 它具有不需要的底部偏移。

在视觉上,此偏移量看起来等于 HostFragment 的选项卡栏的高度。你们知道如何避免这种偏移吗?

还值得一提的是,所有 RecyclerView 的 子级都有唯一的 transitionNames

最佳答案

我知道这个问题很古老,但我一直在与类似的问题作斗争。

最后我所要做的就是将父 View xml 中的 android:clipChildren 标志更改为 false。

关于Android共享元素过渡,起始位置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33356053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com