我正在尝试找到使用自定义字体作为工具栏标题并将其居中在工具栏(客户需求)的正确方法。
目前,我正在使用传统的ActionBar,并将标题设置为空值,然后使用setCustomView
将我的自定义字体TextView放置并使用ActionBar.LayoutParams使其居中。
有更好的方法吗?可以使用新的Toolbar作为我的ActionBar。
我正在尝试找到使用自定义字体作为工具栏标题并将其居中在工具栏(客户需求)的正确方法。
目前,我正在使用传统的ActionBar,并将标题设置为空值,然后使用setCustomView
将我的自定义字体TextView放置并使用ActionBar.LayoutParams使其居中。
有更好的方法吗?可以使用新的Toolbar作为我的ActionBar。
Typeface face= Typeface.createFromAsset(getAssets(), "font/font.ttf"); // your custom font
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTypeface(face);
setSupportActionBar(toolbar);
其他教程: