【发布时间】:2018-05-09 00:31:26
【问题描述】:
我有一个我在 Xamarin Forms 项目中创建的 Android 工具栏:
var toolbar = activity.LayoutInflater
.Inflate(FormsAppCompatActivity.ToolbarResource, null)
.JavaCast<Android.Support.V7.Widget.Toolbar>();
我可以通过以下操作轻松设置背景颜色和其他布局参数:
toolbar.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
toolbar.SetBackgroundColor(backgroundColor.ToAndroid());
但是,我想不出任何以编程方式设置字体大小的方法,因为要设置的方法是:
toolbar.SetTitleTextAppearance(Context context, int resId)
而且我不想使用已配置的资源对其进行设置。我想用字体大小和/或其他样式属性动态设置它。我该怎么做?
【问题讨论】:
-
形成你的代码,我不知道你是如何使用工具栏的。你能显示你的工具栏的布局吗?我通常使用
Toolbar作为ViewGroup,我可以添加一个TextView作为标题,然后我可以findViewbyID找到标题,我可以改变任何我想要的。
标签: android xamarin xamarin.android android-actionbar