0

we have a few apps where we support android from Version 6 min to 10.

Now I have a bottom Navigation bar (tabbedpage) 5 tabs and when tapping on it , the title gets cut off. In android 9 I have implemented as recommended https://montemagno.com/control-text-size-on-android-bottom-navigation/

and works ,but it does not work on android 7 as it clearly says "android 9"

<resources xmlns:tools="http://schemas.android.com/tools">
    <dimen name="design_bottom_navigation_text_size" tools:override="true">10sp</dimen>
    <dimen name="design_bottom_navigation_active_text_size" tools:override="true">12sp</dimen>
</resources>

Can the size of the text be changed on android 7 and how? I am using the latest xamarin.forms

developer9969
  • 4,628
  • 6
  • 40
  • 88
  • It should work on Android 7 as well if you are using the correct library version. I did not find anything in the link that says that it will work only on Android 9. I think you are confused with the library version and Android OS version. – Nongthonbam Tonthoi Apr 22 '20 at 09:54
  • @NongthonbamTonthoi yes you are right on that article it didnt but does not work on 7. I got confused with https://montemagno.com/xamarin-forms-fully-customize-bottom-tabs-on-android-turn-off-shifting/ – developer9969 Apr 22 '20 at 11:37

1 Answers1

0

You could set the font size in code behind .

in Resource-> Menu

define the tab item

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">
    <item
        android:id="@+id/action_settings_1"
        android:orderInCategory="100"
        android:title="111"
        app:showAsAction="never" />

  <item
        android:id="@+id/action_settings_2"
        android:orderInCategory="100"
        android:title="222"
        app:showAsAction="never" />

  <item
        android:id="@+id/action_settings_3"
        android:orderInCategory="100"
        android:title="333"
        app:showAsAction="never" />
</menu>

in Resource-> Layout

Add the following code in content_main.xml

<android.support.design.widget.BottomNavigationView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/bottomNavigationView"
    //... other property

    app:menu="@menu/menu_main" />

in MainActivity

 BottomNavigationView bottomNavigationView = FindViewById<BottomNavigationView>(Resource.Id.bottomNavigationView);
TextView textView = (TextView)bottomNavigationView.FindViewById(Resource.Id.action_settings).FindViewById(Resource.Id.largeLabel);
textView.TextSize=12;
Lucas Zhang
  • 18,630
  • 3
  • 12
  • 22
  • Thanks for your reply the tab items are build dynamically in forms viewmodel and I cannot change that bit. are you saying 1)Create content_main.xml in resource.layout. 2)in MainActivity add the bottomview code after base.OnCreate(bundle) where do you get "Resource.Id.action_settings and Resource.Id.largeLabel. I cannot find it in intellesense – developer9969 Apr 22 '20 at 11:34
  • Could you share your sample so that I can test it on my side ? – Lucas Zhang Apr 22 '20 at 12:12
  • my bad the "dimens.xml"actually work it fooled me because "10sp" worked 1 phone that happened to be android 9 and didnt on android 7 but I reduced the size to 08sp and worked. is there a something like that handles different device screens eg "smallsize" i guess 8sp will be too small on bigger devices – developer9969 Apr 22 '20 at 12:55
  • You could check https://stackoverflow.com/questions/49398345/xamarin-forms-change-icon-text-size-in-tabbedpage-tabs . – Lucas Zhang Apr 22 '20 at 13:16