I'm working on putting a Toolbar
to screen bottom. After I hide the toolbar title, the title still occupies spaces.
My question is: how can I remove the space?
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
In my Activity's onCreate()
:
toolbar = (Toolbar)findViewById(R.id.bar_bottom);
setSupportActionBar(toolbar);
getSupportActionBar().setSubtitle("");
getSupportActionBar().setDisplayShowTitleEnabled(false);
and in same activity's onCreateOptionsMenu
and onOptionsItemSelected
:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_bar_bottom, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
and in my layout:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".WelcomeActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/lbl_test"
android:layout_width="match_parent"
android:layout_height="20sp"
android:text=""
/>
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/bar_bottom"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="?attr/colorPrimary"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
and the Menu:
<?xml version="1.0" encoding="utf-8"?>
<menu 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"
tools:context=".WelcomeActivity">
<item
android:id="@+id/btn_1"
android:orderInCategory="100"
android:title="Button 1"
app:showAsAction="always" />
<item
android:id="@+id/btn_2"
android:orderInCategory="200"
android:title="Button 2"
app:showAsAction="always" />
<item
android:id="@+id/btn_3"
android:orderInCategory="300"
android:title="Button 3"
app:showAsAction="always" />
<item
android:id="@+id/btn_4"
android:orderInCategory="400"
android:title="Button 4"
app:showAsAction="always" />
</menu>