【发布时间】:2017-03-12 22:26:58
【问题描述】:
我正在使用托管ListFragment 的活动。从 ListFragment 我可以打开一个DetailTabsFragment。这两个选项卡包含两个片段:DetailFragment 和 ReviewFragment。
我在DetailFragment中设置了标题,代码如下:
((AppCompatActivity)getActivity()).getSupportActionBar().setTitle("my title");
但正如您在屏幕截图中看到的那样,标题在第一个字符处被截断。这是为什么呢?
DetailTabsFragment的xml布局:
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:elevation="0dp">
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:tabMode="fixed"
app:tabGravity="fill"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"/>
</android.support.design.widget.AppBarLayout>
一个mainActivity的布局:
<android.support.design.widget.CoordinatorLayout
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.dcs.shows.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
【问题讨论】:
-
你检查过这个吗? stackoverflow.com/q/15389663/2745495
-
是的,我在问我的问题之前发现它没有用。
标签: android android-actionbar material-design android-toolbar