Creating a custom toolbar in android -
i trying create custom extended toolbar in android edit text in toolbar. layout want implement looks this
the code have written implement this:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity"> <android.support.v7.widget.toolbar android:id="@+id/my_awesome_toolbar" android:layout_height="256dp" android:layout_width="match_parent" android:minheight="?attr/actionbarsize" android:background="?attr/colorprimary" > <edittext android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/searchbox" android:layout_alignparentbottom="true" android:text="test" android:background="#ffffff" /> </android.support.v7.widget.toolbar>
and activity has following code
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); toolbar toolbar = (toolbar) findviewbyid(r.id.my_awesome_toolbar); if (toolbar != null) { setsupportactionbar(toolbar); getsupportactionbar().setdisplayshowtitleenabled(false); getsupportactionbar().setdisplayshowhomeenabled(false); }}
but instead this:
there not lot of tutorials customizing extended toolbar appreciate help.
i think need add gravity="bottom" on toolbar settings like:
<android.support.v7.widget.toolbar android:id="@+id/my_awesome_toolbar" android:gravity="bottom" android:layout_height="256dp" android:layout_width="match_parent" android:minheight="?attr/actionbarsize" android:background="?attr/colorprimary">
i had add margin bottom of layout edit appear should text bottom of edit.
or can set layout_gravity on edittext.
<edittext android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginbottom="16dp" android:layout_gravity="bottom" android:id="@+id/searchbox" android:text="test" android:background="#ffffff"/>
i'm surprised alignparentbottom compiles. don't believe toolbar inherits relativelayout.
edit - here's complete layout:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity"> <android.support.v7.widget.toolbar android:id="@+id/my_awesome_toolbar" android:layout_height="264dp" android:layout_width="match_parent" android:layout_alignparentbottom="true" android:minheight="?attr/actionbarsize" android:background="?attr/colorprimary"> <edittext android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginbottom="16dp" android:layout_gravity="bottom" android:id="@+id/searchbox" android:text="test" android:background="#ffffff"/> </android.support.v7.widget.toolbar> </relativelayout>
which results in this:
Comments
Post a Comment