[英]How to add views to Fragment B that are not involved in a shared element transition from Fragment A?
So I have a recycler view item that looks like this: Transition View Start所以我有一个看起来像这样的回收器视图项目:过渡视图开始
And I want to end up with this: Transition View End我想以这个结束: Transition View End
The problem I keep getting is an index out-of-bounds exception.我不断遇到的问题是索引越界异常。 So the start has 6 views that transition and all have the appropriate transition name based on a unique id.所以开始有 6 个过渡视图,并且所有视图都具有基于唯一 ID 的适当过渡名称。 The end view has all 6 but 2 more, the small water and thermometer images.最终视图有 6 个,但还有 2 个,小水和温度计图像。 Those two have no transition names.这两个没有过渡名称。 Yet they keep getting added to a list that stores the transition views.然而,它们不断被添加到存储过渡视图的列表中。 The following code is in DefaultSpecialEffectsController.java - line 701以下代码在 DefaultSpecialEffectsController.java - 第 701 行
void captureTransitioningViews(ArrayList<View> transitioningViews, View view) {
if (view instanceof ViewGroup) {
if (!transitioningViews.contains(view)
&& ViewCompat.getTransitionName(view) != null) {
transitioningViews.add(view);
}
ViewGroup viewGroup = (ViewGroup) view;
int count = viewGroup.getChildCount();
for (int i = 0; i < count; i++) {
View child = viewGroup.getChildAt(i);
if (child.getVisibility() == View.VISIBLE) {
captureTransitioningViews(transitioningViews, child);
}
}
} else {
if (!transitioningViews.contains(view)) {
transitioningViews.add(view);
}
}
}
And the index out of bounds occurs here FragmentTranstionImpl.java - line 176并且索引越界发生在这里 FragmentTranstionImpl.java - 第 176 行
void setNameOverridesReordered(final View sceneRoot,
final ArrayList<View> sharedElementsOut, final ArrayList<View> sharedElementsIn,
final ArrayList<String> inNames, final Map<String, String> nameOverrides) {
final int numSharedElements = sharedElementsIn.size();
final ArrayList<String> outNames = new ArrayList<>();
for (int i = 0; i < numSharedElements; i++) {
final View view = sharedElementsOut.get(i);
final String name = ViewCompat.getTransitionName(view);
outNames.add(name);
if (name == null) {
continue;
}
ViewCompat.setTransitionName(view, null);
final String inName = nameOverrides.get(name);
for (int j = 0; j < numSharedElements; j++) {
if (inName.equals(inNames.get(j))) {
ViewCompat.setTransitionName(sharedElementsIn.get(j), name);
break;
}
}
}
Is it possible to add the two small icons and in general any view, without them being in the starting transition view in recycler view in Fragment A?是否可以添加两个小图标和一般的任何视图,而它们不在 Fragment A 的回收器视图中的起始过渡视图中?
This is a bug in Fragments , specifically fixed in Fragment 1.3.5 .这是 Fragment 中的一个错误,专门在Fragment 1.3.5 中修复。 You'll need to upgrade to that version.您需要升级到该版本。
implementation "androidx.fragment:fragment:1.3.5"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.