DawidPi DawidPi - 22 days ago 6
Android Question

Android - non-floating toolbar

my problem is, that with appcompat I am able only to create a toolbar, which is floating. In my scenario this looks pretty ugly. Could not find any tutorial/solution, that would allow to create toolbar a non-floatable one. Do you have any ideas?

My current implementation:

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>


UPDATE:

by floating I mean, that it's not aligned to top and right left border. Instead it's just flying attached to nothing.

Floating Toolbar with Appcompat this is a sample with floating toolbar.

https://developer.android.com/training/appbar/index.html in image here here is non-floating toolbar.

Answer

Without the complete layout XML, it is hard to provide a good answer, but based on your description of the problem, it sounds like the root layout (or whatever View contains your Toolbar has padding set on it.

Remove all padding from the Toolbar's parent and you should get what you are looking for.

Comments