android - Collapsing toolbar title overlaps with my menu icons -
i using collapsing toolbar in project working on currently. setting title of collapsing toolbar code problem if title big overlaps menu icons in toolbar. how can fix issue?
my xml code:
<android.support.design.widget.appbarlayout android:layout_width="match_parent" android:layout_height="205dp" android:fitssystemwindows="true" android:theme="@style/apptheme.appbaroverlay"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/agent_profile_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" app:contentscrim="?attr/colorprimary" app:expandedtitlemarginbottom="87dp" app:expandedtitlemarginstart="130dp" app:expandedtitletextappearance="@style/expandedappbar" app:layout_scrollflags="scroll|exituntilcollapsed"> <relativelayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fff" android:fitssystemwindows="true" app:layout_collapsemode="parallax"> <imageview android:id="@+id/backdrop" android:layout_width="match_parent" android:layout_height="170dp" android:fitssystemwindows="true" android:scaletype="centercrop" android:src="@drawable/back" /> <relativelayout android:layout_width="match_parent" android:layout_height="170dp" android:background="#66000000"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_marginbottom="8dp" android:layout_marginleft="130dp" android:orientation="vertical"> <textview android:id="@+id/lbl_agent_profile_position" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/lbl_agent_profile_name" android:layout_marginbottom="5dp" android:ellipsize="end" android:maxlines="1" android:text="real estate professional @ exit alliance realty" android:textappearance="?android:attr/textappearancesmall" android:textcolor="#fff" android:textsize="12sp" android:typeface="sans" /> <textview android:id="@+id/lbl_agent_profile_ibaaxid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#33ffffff" android:paddingbottom="1dp" android:paddingend="3dp" android:paddingleft="3dp" android:paddingright="3dp" android:paddingstart="3dp" android:paddingtop="1dp" android:text="ibaax id : 123456789" android:textappearance="?android:attr/textappearancesmall" android:textcolor="#fff" android:textsize="12sp" android:typeface="sans" /> </linearlayout> </relativelayout> <linearlayout android:id="@+id/lnr_img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="2dp" android:background="#fff" android:layout_marginleft="10dp" android:layout_marginstart="10dp" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true"> <imageview android:id="@+id/img_agent_profile_image" android:layout_width="110dp" android:layout_height="110dp" android:scaletype="centercrop" android:src="@drawable/no_profile" /> </linearlayout> <button android:layout_width="wrap_content" android:layout_height="22dp" android:layout_below="@+id/backdrop" android:layout_marginleft="8dp" android:layout_margintop="8dp" android:layout_torightof="@+id/lnr_img" android:background="#4d6088" android:paddingend="3dp" android:paddingleft="3dp" android:paddingright="3dp" android:paddingstart="3dp" android:text="write review" android:textallcaps="false" android:textsize="12sp" /> </relativelayout> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" app:layout_collapsemode="pin" app:popuptheme="@style/apptheme.popupoverlay" /> </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout>
and code in activity's oncreate method:
setcontentview(r.layout.activity_agent_profile2); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); getsupportactionbar().setdisplayhomeasupenabled(true); //getsupportactionbar().settitle("name"); agent = (agent) getintent().getserializableextra("agent"); collapsingtoolbarlayout collapsingtoolbar = (collapsingtoolbarlayout) findviewbyid(r.id.agent_profile_toolbar); collapsingtoolbar.settitle(agent.name);
i fixed somehow. don't why work though. had give separate styles expandedtitle , collapsetitle different textsizes. if same textsizes work. here styles below,
<style name="expandedappbar" parent="@android:style/textappearance.medium"> <item name="android:textsize">20sp</item> <item name="android:textstyle">bold</item> <item name="android:ellipsize">end</item> <item name="android:maxlines">1</item> <item name="android:width">100dp</item> </style> <style name="collapseappbar" parent="@android:style/textappearance.medium"> <item name="android:textsize">18sp</item> <item name="android:textstyle">bold</item> </style>
and layout:
<android.support.design.widget.collapsingtoolbarlayout android:id="@+id/agent_profile_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" app:contentscrim="?attr/colorprimary" app:expandedtitlemarginbottom="87dp" app:expandedtitlemarginstart="130dp" app:expandedtitletextappearance="@style/expandedappbar" app:collapsedtitletextappearance="@style/collapseappbar" app:layout_scrollflags="scroll|exituntilcollapsed">
and screenshot prove works,
Comments
Post a Comment