与英雄的元素场景转换抛出层超过最大值。由GPU支持尺寸最大值、抛出、场景、元素

由网友(轻熟杀无赦)分享简介:我试图做一个ListView到详细信息页面的图像之间的Andr​​oid 5.0的英雄转变。但是,大约50%我的图片Android的崩溃与下面的异常。我的图片600x400,但我想他们更改为黑白200x100,但得到了同样的错误。当它的工作原理,它看起来很棒,但我不能看到各种图像之间的差异。真的不能确定为什么它声称层太...

我试图做一个ListView到详细信息页面的图像之间的Andr​​oid 5.0的英雄转变。但是,大约50%我的图片Android的崩溃与下面的异常。我的图片600x400,但我想他们更改为黑白200x100,但得到了同样的错误。当它的工作原理,它看起来很棒,但我不能看到各种图像之间的差异。真的不能确定为什么它声称层太大了,任何人都得到了线索?

 私人无效handleNewsItemClicked(适配器视图<>为arg0,查看viewClicked,INT ARG2){
    TopNewsItem项目=((TopNewsItem)arg0.getAdapter()的getItem(ARG2)。);
        意向意图=新的意图(getActivity(),TopNewsDetailsActivity.class);
        intent.putExtra(TopNewsDetailsActivity.ARGS_ID,item.getGuid()的getId());
        intent.putExtra(TopNewsDetailsActivity.ARGS_IMAGE,IMAGEURL);
        如果(Build.VERSION.SDK_INT> = 21){
            ActivityOptions选项= ActivityOptions
                    .makeSceneTransitionAnimation(this.getActivity(),
                            viewClicked.findViewById(R.id.image),article_image);
            。this.getActivity()startActivity(意向,options.toBundle());
        }其他
            。getActivity()startActivity(意向);
    }
}

W / OpenGLRenderer(18137):层超过最大值。由GPU支持的尺寸(1080x4628,上限= 4096×4096)
D / AndroidRuntime(18137):关闭虚拟机
V / GAV3(18137):螺纹[主,5,主]:跟踪异常:IllegalStateException异常(@MessageQueue:nativePollOnce:-2){}主力
/ AndroidRuntime(18137):致命异常:主要
E / AndroidRuntime(18137):工艺:myapp.app,PID:18137
E / AndroidRuntime(18137):java.lang.IllegalStateException:无法为RelativeLayout的创建图层
E / AndroidRuntime(18137):在android.os.MessageQueue.nativePollOnce(本机方法)
E / AndroidRuntime(18137):在android.os.MessageQueue.next(MessageQueue.java:143)
E / AndroidRuntime(18137):在android.os.Looper.loop(Looper.java:122)
E / AndroidRuntime(18137):在android.app.ActivityThread.main(ActivityThread.java:5221)
E / AndroidRuntime(18137):在java.lang.reflect.Method.invoke(本机方法)
E / AndroidRuntime(18137):在java.lang.reflect.Method.invoke(Method.java:372)
E / AndroidRuntime(18137):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:899)
E / AndroidRuntime(18137):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
 

解决方案

淡出过渡将使用硬件层,当你的观点确实有hasOverlappingRendering()返回true。这是为性能进行。你必须有很多意见都分别淡出。

您有几个选项。一个是你的意见有hasOverlappingRendering返回false。这可能无法在所有的情况下,但也可以是足以解决问题。请记住,这意味着,包含次不应重叠!

二是单独过渡更少的看法。就应该一起淡出ViewGroups transitionGroup =真:你可以通过设置的android做到这一点。例如,如果您有没有背景一个ListView,你最终各个元素分开转换。相反,你可以ListView的transitionGroup属性设置为true,那么他们就会过渡在一起。

- 更新 -

你遇到的问题是,正在逐渐消失在收到的意见太大。我试图在启动活动如下观点:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:的onClick =点击
    >
    <的TextView
        机器人:ID =@ + ID /参考hello world
        机器人:transitionName =你好
        机器人:文本=@字符串/参考hello world
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT/>

< / RelativeLayout的>
 
图显 计算场景应用崛起,致千亿美元GPU市场开启

是的,从Android上的hello world基本的应用程序,给一个ID和transitionName的文字。 onclick句柄只是启动第二个活动,传递的hello world查看共享的元素。第二个活动有一个非常大的TextView,类似于你:

 <滚动型的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:transitionGroup =真
    >
    < RelativeLayout的
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT>
        <的TextView
            机器人:ID =@ + ID /参考hello world
            机器人:transitionName =你好
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignParentRight =真
            机器人:文本=@字符串/参考hello world/>
        <的TextView
            机器人:layout_below =@ + ID /参考hello world
            机器人:文字=Lorem存有....我没有抄我的所有文字
            机器人:TEXTSIZE =30sp
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            />
    < / RelativeLayout的>
< /滚动型>
 

从false(默认值)切换滚动型的transitionGroup为true使得它的工作,因为这样的滚动型正在褪色的滚动型的最大尺寸,而其内容可以是巨大的。

I am trying to do a hero transition in Android 5.0 between an image in a ListView to a details page. But for about 50% of my images Android crashes with the exception below. My images are 600x400 but I tried changing them to 200x100 but got the same error. When it works, it looks great but I cannot see the difference between the various images. Really unsure why it claims the layer is too big, anybody got a clue?

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)

解决方案

The Fade transition will use hardware layers when your view does has "hasOverlappingRendering()" return true. This was done for performance. You must have many views all fading out separately.

You have a couple options. One is for your views to have hasOverlappingRendering return false. This may not be possible in all cases, but it may be enough to solve your problem. Remember that this means that the contained views should not overlap!

The second is to transition fewer views separately. You can do this by setting android:transitionGroup="true" on ViewGroups that should be faded out together. For example, if you have a ListView with no background, you'll end up transitioning each element separately. Instead, you can set the ListView's transitionGroup property to true and then they'll transition together.

-- update --

The problem you're encountering is that the incoming Views that are fading in are too large. I tried the following View in the launching Activity:

<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>

Yes, the hello world basic app from android, giving an id and transitionName to the text. The onClick handler just launches the second Activity, passing the hello world View as a shared element. The second Activity has an extremely large TextView, similar to yours:

<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>

Switching the ScrollView's transitionGroup from false (the default value) to true makes it work because then the ScrollView is being faded in. The ScrollView has a maximum size, while its contents can be enormous.

阅读全文

相关推荐

最新文章