Chr*_*vik 24 android android-transitions android-5.0-lollipop
我试图在Android 5.0中将ListView中的图像与详细信息页面之间进行英雄转换.但是对于我的大约50%的图像,Android崩溃,但下面有例外.我的图像是600x400,但我尝试将它们更改为200x100,但得到了同样的错误.当它工作时,它看起来很棒,但我看不出各种图像之间的差异.真的不确定为什么它声称这个图层太大了,有人知道吗?
private void handleNewsItemClicked(AdapterView<?> arg0, View viewClicked, int arg2) {
TopNewsItem item = ((TopNewsItem)arg0.getAdapter().getItem(arg2));
Intent intent = new Intent(getActivity(), TopNewsDetailsActivity.class);
intent.putExtra(TopNewsDetailsActivity.ARGS_ID, item.getGuid().getId());
intent.putExtra(TopNewsDetailsActivity.ARGS_IMAGE, imageUrl);
if(Build.VERSION.SDK_INT >= 21) {
ActivityOptions options = ActivityOptions
.makeSceneTransitionAnimation(this.getActivity(),
viewClicked.findViewById(R.id.image), "article_image");
this.getActivity().startActivity(intent, options.toBundle());
}else
getActivity().startActivity(intent);
}
}
W/OpenGLRenderer(18137): Layer exceeds max. dimensions supported by the GPU (1080x4628, max=4096x4096)
D/AndroidRuntime(18137): Shutting down VM
V/GAV3 (18137): Thread[main,5,main]: Tracking Exception: IllegalStateException (@MessageQueue:nativePollOnce:-2) {main}
/AndroidRuntime(18137): FATAL EXCEPTION: main
E/AndroidRuntime(18137): Process: myapp.app, PID: 18137
E/AndroidRuntime(18137): java.lang.IllegalStateException: Unable to create layer for RelativeLayout
E/AndroidRuntime(18137): at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime(18137): at android.os.MessageQueue.next(MessageQueue.java:143)
E/AndroidRuntime(18137): at android.os.Looper.loop(Looper.java:122)
E/AndroidRuntime(18137): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime(18137): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18137): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(18137): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime(18137): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Run Code Online (Sandbox Code Playgroud)
Geo*_*unt 48
当视图的"hasOverlappingRendering()"返回true时,Fade转换将使用硬件层.这是为了表现.你必须有许多观点都分开淡出.
你有几个选择.一个是你的观点让hasOverlappingRendering返回false.这在所有情况下都可能无法实现,但它可能足以解决您的问题.请记住,这意味着包含的视图不应重叠!
第二种是分别转换较少的视图.你可以通过在ViewGroups上设置应该一起淡出的android:transitionGroup ="true"来做到这一点.例如,如果您有一个没有背景的ListView,您最终将分别转换每个元素.相反,您可以将ListView的transitionGroup属性设置为true,然后它们将一起转换.
- 更新 -
您遇到的问题是淡入的传入视图太大.我在启动Activity中尝试了以下View:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:onClick="clicked"
>
<TextView
android:id="@+id/hello_world"
android:transitionName="hello"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
是的,来自android的hello world基本应用程序,给文本提供了id和transitionName.onClick处理程序只是启动第二个Activity,将hello world View作为共享元素传递.第二个Activity有一个非常大的TextView,类似于你的:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:transitionGroup="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/hello_world"
android:transitionName="hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/hello_world" />
<TextView
android:layout_below="@+id/hello_world"
android:text="Lorem ipsum.... I didn't copy all of my text"
android:textSize="30sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
将ScrollView的transitionGroup从false(默认值)切换为true使其工作,因为ScrollView正在淡入.ScrollView具有最大大小,而其内容可能非常大.
此问题的根本原因显示在此行的日志中:
W/OpenGLRenderer(18137): Layer exceeds max. dimensions supported by the GPU (1080x4628, max=4096x4096).
您的目标活动的高度为4628,大于GPU支持的最大值 - 4096.
在另一个答案中已经提到的解决方案是创建一个更短的目标活动.类似的问题和答案:崩溃 - 材料设计android 5.0
| 归档时间: |
|
| 查看次数: |
13745 次 |
| 最近记录: |