Dam*_*les 1 xamarin.android xamarin xamarin.forms
默认情况下,背景似乎是白色的,标签是灰色的。这看起来很糟糕。我会将标签的颜色更改为完全黑色。
但我不想单独设置 TextColor。必须有一种方法可以立即更改默认标签颜色。我查看了共享模块,但找不到任何内容。Android 项目中的 sytles.xml 没有灰色。我在哪里可以找到它?
您可以通过多种方式执行此操作,但最简单的方法是使用自定义控件
public class MyLabel : Label
{
public MyLabel ()
{
BackgroundColor = Color.Gray;
}
}
Run Code Online (Sandbox Code Playgroud)
你可以使用这个:
<MyLabel Text="This is testing" />
Run Code Online (Sandbox Code Playgroud)
回复:https : //developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/introduction/
或者
在 App.xaml 中设置样式
<Application.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="TextColor" Value="Gray" />
</Style>
</ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4425 次 |
| 最近记录: |