我可以在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.