Android使用共享元素实现转场动画 错误:Unable to create layer for LinearLayout

来源:互联网 发布:linux关闭nagle算法 编辑:程序博客网 时间:2024/05/17 22:26

最近重构app商品模块,各种app借鉴,发现共享元素的效果挺不错,准备加上。

网上找资料,效果挺不错。然后就开始埋头重构。

先说一下商品界面的布局

使用SlideDetailsLayout 来实现界面上不的详情页和下部的webview图文说明页(产品说的照着京东来。。。)

        <com.zhtx.cs.customview.SlideDetailsLayout            android:id="@+id/sv_switch"            android:layout_width="match_parent"            android:layout_height="match_parent">            <com.zhtx.cs.customview.MyScrollView                android:id="@+id/sv_goods_info"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:scrollbars="none">                <LinearLayout                    android:layout_width="match_parent"                    android:layout_height="wrap_content"                    android:background="@color/c_eeeeee"                    android:orientation="vertical"                    >                    // 要共享的view在这里                    ...                    <LinearLayout                        android:id="@+id/ll_goods_detail_tuijian"                        android:layout_width="match_parent"                        android:layout_height="wrap_content"                        android:orientation="vertical"                        android:background="@color/white_true"                        android:layout_marginTop="@dimen/x9"                        android:visibility="visible">                        <View style="@style/line" />                        <com.bigkoo.convenientbanner.ConvenientBanner                            android:layout_width="match_parent"                            android:layout_height="match_parent"                            android:background="#ffffff"                            app:canLoop="true"                            android:layout_marginLeft="15dp"                            android:layout_marginRight="15dp"                            android:layout_marginTop="15dp"                            android:visibility="visible"/>                    </LinearLayout>                    ...                 </LinearLayout>            </com.zhtx.cs.customview.MyScrollView>            <include layout="@layout/include_item_tab" />        </com.zhtx.cs.customview.SlideDetailsLayout>

ScrollView里边各种乱七八糟的信息,我留下了ConvenientBanner,问题就出现在这里。

在使用转场动画的时候,在小米4手机上华丽丽的卡死了

报的错误是这样的

JNI DETECTED ERROR IN APPLICATION: JNI CallObjectMethod called with pending exception java.lang.IllegalStateException: Unable to create layer for LinearLayout'

说是不可以创建ConvenientBanner这个布局

然后网上各种找资料,网上说在共享元素实现转场动画,Transition group 设置为true,让我们可以将ViewGroup作为一个整体来变换

最后的解决方案是,在最外边的ScrollView加上这一句话

android:transitionGroup="true"

具体的原因大家有兴趣的可以看看 http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0116/2320.html






阅读全文
0 0
原创粉丝点击