android - CollapsingToolbarLayout crash -
i have recyclerview triggers collapsingtoolbarlayout , when try , reopen collapsed toolbar on 4.2.2 crash below. ideas?
java.lang.illegalargumentexception: width , height must > 0 @ android.graphics.bitmap.createbitmap(bitmap.java:638) @ android.graphics.bitmap.createbitmap(bitmap.java:620) @ android.support.design.widget.collapsingtexthelper.ensureexpandedtexture(collapsingtexthelper.java:405) @ android.support.design.widget.collapsingtexthelper.setinterpolatedtextsize(collapsingtexthelper.java:382) @ android.support.design.widget.collapsingtexthelper.calculateoffsets(collapsingtexthelper.java:227) @ android.support.design.widget.collapsingtexthelper.setexpansionfraction(collapsingtexthelper.java:203) @ android.support.design.widget.collapsingtoolbarlayout$offsetupdatelistener.onoffsetchanged(collapsingtoolbarlayout.java:754) @ android.support.design.widget.appbarlayout$behavior.dispatchoffsetupdates(appbarlayout.java:851) @ android.support.design.widget.appbarlayout$behavior.setappbartopbottomoffset(appbarlayout.java:834) @ android.support.design.widget.appbarlayout$behavior.scroll(appbarlayout.java:793) @ android.support.design.widget.appbarlayout$behavior.onnestedscroll(appbarlayout.java:644) @ android.support.design.widget.appbarlayout$behavior.onnestedscroll(appbarlayout.java:583) @ android.support.design.widget.coordinatorlayout.onnestedscroll(coordinatorlayout.java:1428) @ android.support.v4.view.viewparentcompat$viewparentcompatstubimpl.onnestedscroll(viewparentcompat.java:97) @ android.support.v4.view.viewparentcompat.onnestedscroll(viewparentcompat.java:330) @ android.support.v4.view.nestedscrollingchildhelper.dispatchnestedscroll(nestedscrollingchildhelper.java:162) @ android.support.v7.widget.recyclerview.dispatchnestedscroll(recyclerview.java:8306) @ android.support.v7.widget.recyclerview.scrollbyinternal(recyclerview.java:1387) @ android.support.v7.widget.recyclerview.ontouchevent(recyclerview.java:2209) @ android.view.view.dispatchtouchevent(view.java:7127) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2170) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1905)
update:
it looks method in library causes crash checking if either height or width greater 0 -- bitmap requires both > 0:
private void ensureexpandedtexture() { if(this.mexpandedtitletexture == null && !this.mexpandedbounds.isempty() && !textutils.isempty(this.mtexttodraw)) { this.mtextpaint.settextsize(this.mexpandedtextsize); this.mtextpaint.setcolor(this.mexpandedtextcolor); int w = math.round(this.mtextpaint.measuretext(this.mtexttodraw, 0, this.mtexttodraw.length())); int h = math.round(this.mtextpaint.descent() - this.mtextpaint.ascent()); this.mtextwidth = (float)w; if(w > 0 || h > 0) { this.mexpandedtitletexture = bitmap.createbitmap(w, h, config.argb_8888); canvas c = new canvas(this.mexpandedtitletexture); c.drawtext(this.mtexttodraw, 0, this.mtexttodraw.length(), 0.0f, (float)h - this.mtextpaint.descent(), this.mtextpaint); if(this.mtexturepaint == null) { this.mtexturepaint = new paint(); this.mtexturepaint.setantialias(true); this.mtexturepaint.setfilterbitmap(true); } } } }
here xml:
<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/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true"> <android.support.design.widget.appbarlayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="@dimen/series_detail_header_image_height" android:theme="@style/themeoverlay.appcompat.dark.actionbar" app:layout_scrollflags="scroll|exituntilcollapsed" android:fitssystemwindows="true"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollflags="scroll|exituntilcollapsed" android:fitssystemwindows="true" app:contentscrim="?attr/colorprimary" app:expandedtitlemarginstart="48dp" app:expandedtitlemarginend="64dp" app:expandedtitletextappearance="@style/transparenttext"> <framelayout android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" app:layout_collapsemode="parallax" > <imageview android:id="@+id/image_view" android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="centercrop" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="?attr/colorprimary" android:paddingleft="20dp" android:paddingtop="10dp" android:paddingright="10dp" android:layout_gravity="bottom" > <textview android:id="@+id/seriesdetailtitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="american pickers" android:textcolor="@android:color/white" android:textsize="20sp"/> <textview android:id="@+id/seriesdetailtunein" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="tune in tuesdays @ 8pm" android:textcolor="@android:color/white" android:textsize="18sp"/> <linearlayout android:id="@+id/adframe" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingright="@dimen/padding_small" android:visibility="gone"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginright="@dimen/margin_minimal" android:text="@string/show_detail_presented_by" android:textappearance="@android:style/textappearance.devicedefault.small" android:textcolor="@android:color/white" android:textsize="10sp" android:visibility="visible"/> <framelayout android:id="@+id/adview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="visible"/> </linearlayout> </linearlayout> </framelayout> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" app:popuptheme="@style/themeoverlay.appcompat.light" app:layout_collapsemode="pin" /> </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout> <android.support.v4.view.viewpager android:id="@+id/show_view_pager" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:paddingtop="@dimen/toolbar_height" /> <relativelayout android:id="@+id/controls" android:layout_width="match_parent" android:layout_height="@dimen/toolbar_height" android:background="@color/app_primary" app:layout_collapsemode="pin" android:layout_gravity="bottom" app:layout_anchor="@id/show_view_pager" app:layout_anchorgravity="top" > <spinner android:id="@+id/season_spinner" android:layout_width="124dp" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:layout_marginleft="@dimen/series_detail_spinner_left_margin" android:prompt="@string/seasons" android:spinnermode="dropdown" android:dropdownverticaloffset="-48dp" android:dropdownwidth="124dp" android:background="@drawable/selector_spinner_selector_list" /> <android.support.design.widget.tablayout android:id="@+id/tab_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="?attr/colorprimary" android:cliptopadding="false" android:layout_alignparentright="true" android:layout_alignparentbottom="true" android:theme="@style/themeoverlay.appcompat.dark.actionbar" app:tabmode="scrollable" /> </relativelayout>
i filed bug: crash in design support library - collapsingtexthelper class -- if has fix in meantime i'd grateful!
i've discovered cause. in xml collapsingtoolbarlayout set:
app:expandedtitletextappearance="@style/transparenttext"
and style was:
<style name="transparenttext"> <item name="android:textcolor">#00666666</item> </style>
so show text when toolbar collapsed.
turns out styles expandedtitletextappearance , collapsedtitletextappearance need inherit textappearance. style works properly:
<style name="transparenttext" parent="@android:style/textappearance"> <item name="android:textcolor">#00666666</item> </style>
just heads else makes same mistake...
update (7/20/2015): bug appears fixed in v22.2.1 of design support library (https://code.google.com/p/android/issues/detail?id=178674)
Comments
Post a Comment