我正在尝试将工具栏标题文本设置为多行,但它只显示在单行中,15个字符后的文本将成为Android中的Eclipse。请帮帮我们。
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
if(!getSupportActionBar().isTitleTruncated()){
getSupportActionBar().setTitle(job.getJob_title());
}
Spannable text = new SpannableString(job.getJob_title());
text.
setSpan(new ForegroundColorSpan(MainApplication.getIconColor()), 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
getSupportActionBar().setTitle(text);
Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(MainApplication.getIconColor(), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);
答案 0 :(得分:6)
<android.support.v7.widget.Toolbar
android:id="@+id/product_details_toolbar"
style="@style/style.toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/double_height_toolbar"
android:minHeight="?attr/actionBarSize"
android:gravity="top"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >
<TextView
android:id="@+id/product_details_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:paddingTop="@dimen/padding_normal"
style="@android:style/TextAppearance.Holo.Widget.ActionBar.Title.Inverse"
android:maxLines="2" />
</android.support.v7.widget.Toolbar>
试试这个