我想在展开布局时将工具栏标题居中,这是我的代码:
NULL
答案 0 :(得分:1)
您只需更改这两个属性的值
即可 app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
in
<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"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginBottom="60dp">
答案 1 :(得分:1)
尝试将 expandedTitleGravity 添加到 CollapsingToolbarLayout 作为应用属性:
app:expandedTitleGravity="center_horizontal"
示例:
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorPrimary"
app:expandedTitleGravity="center_horizontal"
app:layout_scrollFlags="scroll|exitUntilCollapsed">