我可以在Xamarin.Forms中以编程方式更改styles.xml吗? [英] Can I programmatically change styles.xml in Xamarin.Forms?

查看:86
本文介绍了我可以在Xamarin.Forms中以编程方式更改styles.xml吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个具有可自定义颜色的应用程序.这有时会使列表视图中选定项目的橙色Android默认值看起来很糟糕.我们要更改列表视图的选定项目的颜色.

We have an app that has customizable colors. This makes the orange Android default for selected items in a list view look pretty bad sometimes. We want to change the color of a listview's selected item.

我知道如何在我们页面的代码背后(xaml.cs)中执行此操作,并且我知道您可以在styles.xml中进行静态更改.但是因为列表视图的颜色可以更改,所以无论选择哪种颜色,我们都可能遇到类似的问题.

I know how to do this in the code behinds (xaml.cs) for our pages and I'm aware you can statically change it in the styles.xml. But because the listview color can change, we could be left with a similar issue with whatever color we pick.

是否可以通过代码访问和更改styles.xml值?

Is there a way to access and change the styles.xml values from code?

推荐答案

我们还可以使用Backgroundcolor Bindable属性创建ViewCell渲染器.有了这个,我们可以做的就是在xaml本身中将Bindable属性的所需颜色设置为xaml本身,这将在其渲染器中设置颜色,以便我们可以根据要求提供不同的颜色.

We can also create the ViewCell renderer with the Backgroundcolor Bindable property. With that what we can do is to set the required color to the Bindable property into xaml itself and that will set the color in its renderer so we can provide different colors as per requirement.

这篇关于我可以在Xamarin.Forms中以编程方式更改styles.xml吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆