我正在尝试增加应用中标签的图标大小.图标大小是固定的尝试了很多方法,但没有任何工作,最后尝试了以下,但没有大小的变化.如果任何人可以告诉我正确的方式,我会很高兴.谢谢提前.
这是我的代码,
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.my1));
tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.feed_s));
tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.add_ds1));
tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.history_ds));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
Run Code Online (Sandbox Code Playgroud)
style.xml
<style name="AppTheme.ActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="android:layout_width">50dp</item>
<item name="android:layout_height">50dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
tablayout.xml
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/toolbar"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:theme="@style/AppTheme.ActionBar"/>
Run Code Online (Sandbox Code Playgroud) 我在 Xamarin Forms 中有以下代码:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:XXX;assembly=XXX"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
BackgroundColor="{DynamicResource BarBackgroundColor}"
android:TabbedPage.ToolbarPlacement="Bottom"
android:TabbedPage.BarItemColor="Gray"
android:TabbedPage.BarSelectedItemColor="{DynamicResource BarSelectedItemColor}"
android:TabbedPage.IsSwipePagingEnabled="False"
x:Class="XXX.MainPage">
</TabbedPage>
Run Code Online (Sandbox Code Playgroud)
我想更改Android
侧面Tabbar 文本的大小。我尝试创建自己的风格,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTabLayoutStyle" parent="TextAppearance.Design.Tab">
<item name="android:textSize">5sp</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
而在我的Tabbar.axml
:
<?xml version="1.0" encoding="utf-8"?>
<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/tabs"
android:layout_width="match_parent"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabTextAppearance="@style/MyTabLayoutStyle"/>
Run Code Online (Sandbox Code Playgroud)
我有一种感觉这不起作用,因为我正在使用TabbedPage.ToolbarPlacement="Bottom"
而不是使用TabLayout
,我现在正在使用BottomNavigationView
. 因此,上面的问题,如何在使用TabbedPage.ToolbarPlacement="Bottom"
.