Xaml Xamarin表单Android如何更改选项卡式页面图标大小
Xamarin告诉Android如何更改选项卡式页面图标大小。我正在使用AppCompact主题,我希望在Tabbar中增加选项卡式页面图标大小。axaml您可以创建自定义渲染器并在本机平台中更改图标大小。实际上,您可以覆盖整个选项卡的布局 例如,在PCL中,首先创建一个从TabbedPage继承的类: 公共类MyTabbedPage:TabbedPage { } 然后在Android项目中创建其渲染器,例如:Xaml Xamarin表单Android如何更改选项卡式页面图标大小,xaml,xamarin,xamarin.ios,xamarin.android,xamarin.forms,Xaml,Xamarin,Xamarin.ios,Xamarin.android,Xamarin.forms,Xamarin告诉Android如何更改选项卡式页面图标大小。我正在使用AppCompact主题,我希望在Tabbar中增加选项卡式页面图标大小。axaml您可以创建自定义渲染器并在本机平台中更改图标大小。实际上,您可以覆盖整个选项卡的布局 例如,在PCL中,首先创建一个从TabbedPage继承的类: 公共类MyTabbedPage:TabbedPage { } 然后在Android项目中创建其渲染器,例如: <LinearLayout xmlns:android="http://sch
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitCenter"
android:id="@+id/icon"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<local:MyTabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TabbedPageForms"
x:Class="TabbedPageForms.MainPage">
<local:TodayPage Title="Today" Icon="hamburger.jpg" />
<local:SchedulePage Title="Schedule" Icon="hamburger.jpg" />
</local:MyTabbedPage>
[程序集:ExportRenderTypeOfMyAbbedPage,TypeOfMyAbbedPageRenderer]
名称空间YourNameSpace.Droid
{
公共类MyTabbedPageRenderer:TabbedPageRenderer
{
受保护的覆盖无效SetTabIconTabLayout.Tab选项卡,FileImageSource图标
{
base.SetTabIcontab,图标;
tab.SetCustomViewResource.Layout.MyTableLayout;
var imageview=tab.CustomView.findviewbydresource.Id.icon;
imageview.SetBackgroundDrawabletab.Icon;
}
}
}
我创建的布局如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitCenter"
android:id="@+id/icon"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<local:MyTabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TabbedPageForms"
x:Class="TabbedPageForms.MainPage">
<local:TodayPage Title="Today" Icon="hamburger.jpg" />
<local:SchedulePage Title="Schedule" Icon="hamburger.jpg" />
</local:MyTabbedPage>
代码隐藏:
公共部分类主页面:MyTabbedPage
{
公共主页
{
初始化组件;
}
}
您可以在本机平台中创建自定义渲染器并更改图标的大小。实际上,您可以覆盖整个选项卡的布局 例如,在PCL中,首先创建一个从TabbedPage继承的类: 公共类MyTabbedPage:TabbedPage { } 然后在Android项目中创建其渲染器,例如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitCenter"
android:id="@+id/icon"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<local:MyTabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TabbedPageForms"
x:Class="TabbedPageForms.MainPage">
<local:TodayPage Title="Today" Icon="hamburger.jpg" />
<local:SchedulePage Title="Schedule" Icon="hamburger.jpg" />
</local:MyTabbedPage>
[程序集:ExportRenderTypeOfMyAbbedPage,TypeOfMyAbbedPageRenderer]
名称空间YourNameSpace.Droid
{
公共类MyTabbedPageRenderer:TabbedPageRenderer
{
受保护的覆盖无效SetTabIconTabLayout.Tab选项卡,FileImageSource图标
{
base.SetTabIcontab,图标;
tab.SetCustomViewResource.Layout.MyTableLayout;
var imageview=tab.CustomView.findviewbydresource.Id.icon;
imageview.SetBackgroundDrawabletab.Icon;
}
}
}
我创建的布局如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="fitCenter"
android:id="@+id/icon"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<local:MyTabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TabbedPageForms"
x:Class="TabbedPageForms.MainPage">
<local:TodayPage Title="Today" Icon="hamburger.jpg" />
<local:SchedulePage Title="Schedule" Icon="hamburger.jpg" />
</local:MyTabbedPage>
代码隐藏:
公共部分类主页面:MyTabbedPage
{
公共主页
{
初始化组件;
}
}
我怎样才能为iOS做同样的事情?我怎样才能为iOS做同样的事情?