Xaml android中的Xamarin表单-样式
根据本教程,我最近在我的Xamarin应用程序中实现了暗模式支持: 我使用App.xaml中定义的样式设置标签颜色,如下所示:Xaml android中的Xamarin表单-样式,xaml,xamarin.forms,colors,Xaml,Xamarin.forms,Colors,根据本教程,我最近在我的Xamarin应用程序中实现了暗模式支持: 我使用App.xaml中定义的样式设置标签颜色,如下所示: <Style x:Key="label" TargetType="Label"> <Setter Property="TextColor" Value="{DynamicResource label}"/> </Style> <Style
<Style x:Key="label" TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource label}"/>
</Style>
<Style x:Key="labelLight" TargetType="Label">
<Setter Property="TextColor" Value="{DynamicResource labelLight}"/>
</Style>
这就是我遇到麻烦的地方,我的Android版本的应用程序无法识别这些颜色(所有颜色都是浅灰色的),我的应用程序也无法在iOS 12及更低版本下运行。我不知道如何解决这个问题。例如在android活动中
[Activity(Label = "@string/app_name", Theme = "@style/MyTheme", MainLauncher =true)]
public class MainActivity : AppCompatActivity{
...
}
然后在参考资料/values/styles.xml中:
<!-- Base application theme. -->
<style name="MyTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"> // base theme to use Theme.AppCompat.DayNight
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorPrimary">#ff29b6f6</item>
</style>
//使用theme.AppCompat.DayNight的基本主题
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
@颜色/原色暗
#ff29b6f6
你可以阅读。在android中,你是否将基本主题更新为使用
theme.AppCompat.DayNight
?在ios中,它似乎支持ios 13之后的黑暗模式。我没有更新我的基本主题,你能帮我做吗?我需要在我的info.plist中将OS target设置为13.0?现在可以吗?看起来你链接的文章正是我想要的,谢谢。
<!-- Base application theme. -->
<style name="MyTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"> // base theme to use Theme.AppCompat.DayNight
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:colorPrimary">#ff29b6f6</item>
</style>