Я использую CollapsinToolbarLayout
, и я включил панель инструментов TextView
внутри моего Toolbar
и хочу сделать ее центрированной.
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
android:fitsSystemWindows="true">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:layout_gravity="center"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
Как видно выше, я установил android:layout_gravity="center"
и ожидаю, что мои TextView
будут сосредоточены внутри моих Toolbar
Но это результат, который я получаю.
![enter image description here](https://i.stack.imgur.com/cJrJv.jpg)
Я использую View
внутри других не CollapsingToolbarLayout
с, и они показывают в соответствии с установленной мной силой тяжести, но я не могу заставить ее работать с CollapsingToolbarLayout
. Так что я полагаю, что он как-то связан с CollapsingToolbarLayout
или его родителем AppBarLayout
, но не может понять, что именно.
Почему у меня такое поведение при работе с CollapsingToolbarLayout
?