片段更改时,如何在Toolbar
内更改Textview
?我的工具栏位于BaseActivity
,所以我可以在所有活动中使用。片段中的工具栏标题
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="4dp"
android:layout_marginLeft="20dp"
ndroid:layout_marginRight="attr/actionBarSize"
android:layout_marginTop="4dp"
android:textColor="@color/colorAccent2"
android:textSize="19sp"
tools:ignore="HardcodedText" />
</FrameLayout>
</android.support.v7.widget.Toolbar>
这didnt工作。因为我的片段是在标签布局,它给所有我的片段标题相同的标题 –
我编辑了我的答案。请尝试。 –
它看起来像工作,但没有更新标题,如果我改变e.x的片段从第一到第二或从第三到第二。为什么? –