Toolbar with separator at the bottom

Asked

Viewed 256 times

3

I’m using the Toolbar, but wanted the bottom of it to have a line of another color that delimited it, as shown in the image,

Tela com uma toolbar no topo em tom predominentemente cinza claro, mas com um separador cinza escuro entre ela e o restante da tela

To achieve this effect the only thing I remember is using a ImageView. Is there any other better way to do this?

1 answer

2

Instead of a Imageview use a View with the background the color you want and set the height in android:layout_height

<android.support.v7.widget.Toolbar

        android:id="@+id/toolbar"
        ........
        ........
        ........>

    <View
        android:id="@+id/LinhaHorizontal"
        android:layout_width="match_parent"
        android:layout_height= "2dp"
        android:background="@color/gray" 
        android:layout_gravity="bottom"/>

</android.support.v7.widget.Toolbar>
  • It doesn’t work. I put it exactly like you said, but it looks exactly the same without the gray bar :\

  • It works, you have to increase the value of layout_height.

  • It won’t take up all of Toobar, just the middle part between the left navigation icon and points on the right menu. If you do not use any of them the line can be extended to the entire length using app:contentInsetStart="0dp" and app:contentInsetEnd="0dp"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.