RaviKoradiya / Toolbar-Center-Title

A Library for align title on ActionBar.
20 stars 3 forks source link

Not working with androidx.appcompat.widget.Toolbar #1

Open tmm1 opened 5 years ago

tmm1 commented 5 years ago

I tried to use this library as such:

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_alignParentTop="true"
        android:background="@color/bar_tint"
        android:theme="@style/ToolbarTheme"
        app:popupTheme="@style/PopupTheme"
        bind:centerTitle="@{true}"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

but the text is not centered.

Does it work with androidx?

masqueNada commented 5 years ago

@tmm1 I copied this file from the library into my project /Toolbar-Center-Title/library/src/main/java/com/ravikoradiya/library/CenterTitle.kt changed following toolbar import to corresponding androidx one :

import android.support.v7.widget.Toolbar
import androidx.appcompat.widget.Toolbar 

and it worked like a charm with androidx :) PS: No need to add a gradle dependency this way.

soltesu29 commented 4 years ago

<androidx.appcompat.widget.Toolbar android:layout_height="?android:attr/actionBarSize" android:layout_width="match_parent" android:id="@+id/toolbar" android:layout_alignParentTop="true" android:background="@color/colorAccent"

    />
soltesu29 commented 4 years ago

<androidx.appcompat.widget.Toolbar android:layout_height="?android:attr/actionBarSize" android:layout_width="match_parent" android:id="@+id/toolbar" android:layout_alignParentTop="true" android:background="@color/colorAccent"

    />
thecreativedg commented 4 years ago

@masqueNada can you explain more how you did it? Where to put what?