我正在使用Xamarin.Forms和可移植类库构建应用程序。我有一个选项卡式页面。我想更改选项卡式页面指示器的颜色。更改其余布局是我已经管理的事情,我唯一需要做的就是更改浅蓝色的选项卡式页面指示器,如下所示:
我在Xamarin.Droid中找不到任何可以使用的东西。这是使用内容创建选项卡式页面的代码:
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#解决方案。
先感谢您。
如果您在Android平台项目中使用AppCompat,请在TabLayout axml文件中使用tabIndicatorColor属性执行以下操作:
<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" />
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句