I'm trying to add another action bar or menu to the bottom of my activity layout and keep the top action bar.
Something like this :
Here is my Layout :
<LinearLayout 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"
android:orientation="vertical"
tools:context="com.example.yasser.version6.PublierActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:id="@+id/user"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_margin="4dp"
android:id="@+id/profil_image"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="218dp"
android:layout_marginEnd="218dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine|textCapSentences"
android:ems="10"
android:background="#00000000"
android:layout_margin="4dp"
android:hint="Écriver quelque chose..."
android:id="@+id/publication_text"
android:maxLength="150"
android:textSize="15dp"
android:maxLines="3"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<requestFocus />
</EditText>
</LinearLayout>
<ImageView
android:layout_width="fill_parent"
android:layout_height="@dimen/image_size"
android:id="@+id/publication_image"
android:layout_weight="1"
android:padding="0dp"
android:background="@drawable/default_image"
android:layout_marginTop="5dp"
android:scaleType="fitXY"
android:layout_below="@+id/user" />
</RelativeLayout>
I've tried to add a custom RelativeLayout which look almost like an action bar, but the toolbar goes up and mess up everything.
I made a custom Bottom bar with exact Height of ?attr/actionBarSize and ` layout_alignParentBottom="true" to put it in bottom.
Now goto Manifest.xml and in your activity tag put
This will resize the layout on keyboard opening.
As far as i know there is no option to move the
ActionBar
entirely to the bottom. But still it is possible to display few items at the bottom. for that you need to do this:Just add
android:uiOptions="splitActionBarWhenNarrow"
to youractivity
tag in theAndroidManifest.xml
like this...<activity android:name=".MainActivity" android:uiOptions="splitActionBarWhenNarrow">
You can read more here and here
Hope it helps. :)
Creating custom bottom toolbar
I've already created a simple app which should demonstrate you how to begin
Creating a custom ViewGroup
Here's my
activity_main.xml
layout file:As you can see my parent
ViewGroup
isRelativeLayout
, which simply allows me to create a view at the bottom of screen.Notice that I set layout padding to zero (I think: setting layout margin to zero here is not necessary, the same effect). If you'd change it, the toolbar won't use full width and it won't stick with bottom of the screen.
Then I added a Linear Layout with hardcoded height which is:
I wanted it, that my bottom toolbar would take full available width so I set it as
match_parent
.Next, I added some
ImageButton
views with images from Android library.There you have two possibilities:
if you really want to have a toolbar like in above example just remove in every
ImageButton
view this line:After removing weights and some buttons you would get a view pretty similar to expected:
weight
as in this mine example.Now let's go to my AndroidManifest.xml
In that file I'd added as you can see only one additional line:
to make sure that device keyboard won't hide my custom bottom toolbar.
If you have any question, please free to ask. I would answer them as quickly as possible.
Hope it help
That is a split action bar. It is available for handset devices with a screen width of 400dp< To enable split action bar, simply add uiOptions="splitActionBarWhenNarrow" to your or manifest element.
Edit: The second image is indeed not a split action bar. These are just buttons with the buttonBarButtonStyle attribute. Look into this here.
You can simply Add a toolbar and set it to bottom and simply can create your own custom layout.