本文介绍了如何更改CollapsingToolbarLayout字体和大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改 CollapsingToolbarLayout
字体大小及其字体。我怎么能做到这一点?
解决方案看起来像我有解决方案:
pre $私人无效makeCollapsingToolbarLayoutLooksGood(CollapsingToolbarLayout collapsingToolbarLayout){
尝试{
final Field field = collapsingToolbarLayout.getClass()。getDeclaredField(mCollapsingTextHelper);
field.setAccessible(true);
final Object object = field.get(collapsingToolbarLayout);
final字段tpf = object.getClass()。getDeclaredField(mTextPaint);
tpf.setAccessible(true);
$ b $((TextPaint)tpf.get(object))。setTypeface(Typeface.createFromAsset(getAssets(),Roboto-Bold.ttf));
((TextPaint)tpf.get(object))。setColor(getResources()。getColor(R.color.ice));
} catch(忽略例外){
}
}
pre $私人无效makeCollapsingToolbarLayoutLooksGood(CollapsingToolbarLayout collapsingToolbarLayout){
尝试{
final Field field = collapsingToolbarLayout.getClass()。getDeclaredField(mCollapsingTextHelper);
field.setAccessible(true);
final Object object = field.get(collapsingToolbarLayout);
final字段tpf = object.getClass()。getDeclaredField(mTextPaint);
tpf.setAccessible(true);
$ b $((TextPaint)tpf.get(object))。setTypeface(Typeface.createFromAsset(getAssets(),Roboto-Bold.ttf));
((TextPaint)tpf.get(object))。setColor(getResources()。getColor(R.color.ice));
} catch(忽略例外){
}
}
I want to change CollapsingToolbarLayout
font size and its typeface. How I can achieve that?
解决方案
Looks like I have solution:
private void makeCollapsingToolbarLayoutLooksGood(CollapsingToolbarLayout collapsingToolbarLayout) {
try {
final Field field = collapsingToolbarLayout.getClass().getDeclaredField("mCollapsingTextHelper");
field.setAccessible(true);
final Object object = field.get(collapsingToolbarLayout);
final Field tpf = object.getClass().getDeclaredField("mTextPaint");
tpf.setAccessible(true);
((TextPaint) tpf.get(object)).setTypeface(Typeface.createFromAsset(getAssets(), "Roboto-Bold.ttf"));
((TextPaint) tpf.get(object)).setColor(getResources().getColor(R.color.ice));
} catch (Exception ignored) {
}
}
这篇关于如何更改CollapsingToolbarLayout字体和大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!