如何更改 Xamarin.Droid 中标签页指示器的颜色? [英] How to change color of tabbed page indicator in Xamarin.Droid?

查看:27
本文介绍了如何更改 Xamarin.Droid 中标签页指示器的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Xamarin.Forms 和可移植类库构建应用程序.我有一个标签页.我想更改标签页指示器的颜色.更改布局的其余部分是我已经管理的事情,我唯一需要做的就是更改浅蓝色标签页指示器,如下所示:

I'm building an application with Xamarin.Forms and a Portable Class Library. I have a tabbed page. I want to change the color of the tabbed page indicator. Changing the rest of the layout is something I already managed, the only thing I do need is to change the light blue tabbed page indicator like shown below:

我找不到任何可以在 Xamarin.Droid 中工作的东西.这是创建带有内容的标签页的代码:

I couldn't find anything that could work in Xamarin.Droid. This is the code that creates the tabbed page with content:

class TabbedPageTry : TabbedPage
{
    public TabbedPageTry()
    { 
        Title = "TabbedPage";

        var myPages = new CategoryDAO().GetCategories();
        foreach (var item in myPages)
        {
            Children.Add(new TabPage(item.CategoryID) { BindingContext = item });
        }
    }

    public class TabPage : ContentPage
    {
        public TabPage(int categoryID)
        {
            Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);

            var listView = new ListView
            {

                SeparatorColor = Color.FromHex("#101010"),
                ItemsSource = new CourseDAO().GetCourses(),
                IsPullToRefreshEnabled = false,
                BackgroundColor = Color.White,
            };

            this.SetBinding(Page.TitleProperty, "Name");
            Content = listView;
        }
}

因为应用程序是使用 Xamarin.Forms 制作的 Visual Studio,所以我的问题还没有得到解答.我发现的所有问题都是针对 Android 的,这不是我正在寻找的.我需要的是针对我的问题的 C# 解决方案.

Because the application is being made Visual Studio with Xamarin.Forms my question is not answered yet. All the question I found are for Android specific, this is NOT what I am looking for. What I need is the C# solution to my problem.

提前致谢.

推荐答案

如果您是 在您的 Android 平台项目中使用 AppCompat,在您的 TabLayout axml 文件中使用 tabIndicatorColor 属性来执行此操作:

If you are using AppCompat in your Android platform project, in your TabLayout axml file use the tabIndicatorColor property to do this:

<android.support.design.widget.TabLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_tabs"
   ....
    app:tabIndicatorColor="#123456" />

这篇关于如何更改 Xamarin.Droid 中标签页指示器的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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