Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] Expose more customization properties for text on tabs #7713

Open
Basti82b opened this issue Sep 27, 2019 · 12 comments
Open

[Enhancement] Expose more customization properties for text on tabs #7713

Basti82b opened this issue Sep 27, 2019 · 12 comments

Comments

@Basti82b
Copy link

Steps to Reproduce

  1. Load the Xaminals project
  2. Add a word to the ShellContent.Title of Monkeys in AppShell.xaml
  3. Run the app and select the Monkeys tab

Expected Behavior

Tab title is displayed completely.

Actual Behavior

Tab title is cropped.

Basic Information

Version with issue: Xamarin.Forms 4.2.0.815419
Platform Target Frameworks:
Android: 9.0

Screenshots

Screenshot_1569586596
Screenshot_1569586599

@Basti82b Basti82b added s/unverified New report that has yet to be verified t/bug 🐛 labels Sep 27, 2019
@pauldipietro pauldipietro added this to New in Triage Sep 27, 2019
@PureWeen
Copy link
Contributor

PureWeen commented Oct 4, 2019

@Basti82b so I wouldn't call this a bug. The bold text makes it larger so it wraps. Ideally here we'd just have more apis you could use to change the font size so you can adjust the text to fit

In the mean time you could implement a custom ShellItemRenderer and change the font settings of the tabs

@PureWeen PureWeen added t/enhancement ➕ and removed s/unverified New report that has yet to be verified labels Oct 4, 2019
@PureWeen PureWeen moved this from New to External in Triage Oct 4, 2019
@PureWeen PureWeen moved this from External to Ready For Work in Triage Oct 4, 2019
@PureWeen PureWeen added the e/4 🕓 4 label Oct 4, 2019
@PureWeen PureWeen changed the title [Bug] Tab title cropped on selection [Enhancement] Expose more customization properties for text on tabs Oct 4, 2019
@samhouts samhouts removed this from Ready For Work in Triage Oct 4, 2019
@Basti82b
Copy link
Author

@PureWeen Thank you for the pointer. Where can I find "the font settings of the tabs" for Android? Is it right to override OnCreateView?

@Basti82b
Copy link
Author

Basti82b commented Oct 10, 2019

Here is my solution:

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
	var outerlayout = base.OnCreateView(inflater, container, savedInstanceState);
	var bottomView = outerlayout.FindViewById<BottomNavigationView>(Resource.Id.bottomtab_tabbar);

	var bottomNavigationMenuView = (BottomNavigationMenuView)bottomView.GetChildAt(0);
	
	for (int i = 0; i < bottomNavigationMenuView.ChildCount; i++)
	{
		var childAt = bottomNavigationMenuView.GetChildAt(i);

		if (childAt is BottomNavigationItemView bottomNavigationItemView)
		{
			var textView = (TextView)bottomNavigationItemView.FindViewById(Resource.Id.largeLabel);
			textView?.SetAutoSizeTextTypeWithDefaults(AutoSizeTextType.Uniform); //SetTextSize(ComplexUnitType.Sp, 10);
		}
	}
	return outerlayout;
}

@pfedotovsky
Copy link

It seems that issue is tracked here: material-components/material-components-android#139

And it seems to be fixed https://issuetracker.google.com/issues/115754572

You can upgrade to com.google.android.material:material:1.1.0-alpha05 this issue fixed.

But I don't know how to use the updated component in Xamarin.Forms app.

@amgravem
Copy link

You can control text size using James approach: https://montemagno.com/control-text-size-on-android-bottom-navigation/

@PureWeen
Copy link
Contributor

PureWeen commented Nov 20, 2019

@pfedotovsky you should be able to pull in Android X

https://devblogs.microsoft.com/xamarin/androidx-for-xamarin/

And then use the material packages from there

@pfedotovsky
Copy link

@PureWeen I've updated my app to use AndroidX. Could you please elaborate on Material packages I need to use?

@PureWeen
Copy link
Contributor

You'll probably have to wait until we up our material dependency

#9701

There are some style changes we have to address before we can merge that PR though

@pfedotovsky
Copy link

@PureWeen thank you for the prompt reply! I've subscribed to the PR.

My app currently uses Theme.AppCompat.Light.NoActionBar, will I need to update to the Material theme (https://docs.microsoft.com/en-us/xamarin/android/user-interface/material-theme)? I don't need to support Android versions below 5.0.

@PureWeen
Copy link
Contributor

@pfedotovsky nope :-)

@PureWeen
Copy link
Contributor

@pfedotovsky you could try installing this package to see if that works for you

https://www.nuget.org/packages/Xamarin.Google.Android.Material/1.1.0-rc3

@pfedotovsky
Copy link

pfedotovsky commented Mar 22, 2020

@PureWeen works perfectly, thank you! Text is no longer cut off in bottom tab titles :)

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Shell
  
Backlog
Development

No branches or pull requests

5 participants