android - How to show Toolbar's logo, icon, title, subtitle when wrapped in a CollapsingToolbarLayout? -
after android support design library released, wanted implement effect page of twitter profile, in toolbar's title , subtitle changed screen scrolled vertically. tried use coordinatorlayout, appbarlayout, collapsingtoolbarlayout , toolbar android support design library achieve effect. worked expected except toolbar's content couldn't showed or changed wanted. should have been wanting display collapseicon, navigationicon, title, subtitle of toolbar, didn't show though had set them in layout , programmatically. blog said,
note in cases, should call settitle() on collapsingtoolbarlayout, rather on toolbar itself.
if have checked doc, find out collapsingtoolbarlayout focus on settings of title, can nothing collapseicon, navigationicon , subtitle.
so tell me how achieve effect toolbar , collapsingtoolbarlayout? if couldn't able, other things be? has ideas this?
any tips appreciated. in advance.
this issue reported here bug. have experienced 1 of apps. setting topmargin toolbar works me. commented on bug report, here fix, function issue report.
private void fixapi21toolbarbug(toolbar toolbar){ if(build.version.sdk_int!=21) return; //only on api 21 final int resourceid = getresources().getidentifier("status_bar_height", "dimen", "android"); final int result = (resourceid > 0) ? getresources().getdimensionpixelsize(resourceid) * 2 : 0; final collapsingtoolbarlayout.layoutparams params = (collapsingtoolbarlayout.layoutparams) toolbar.getlayoutparams(); params.topmargin -= result; toolbar.setlayoutparams(params); } see result here.

Comments
Post a Comment