Android中的标签页中标签页标题被截断
但在iOS设备中正常运行
我正在使用此代码
public Tabbar()
{
//this.BarTextColor = Color.Maroon;
// New Feed
var navigationNewFeed = new NavigationPage(new NewFeedView());
navigationNewFeed.Title = "News Feed";
navigationNewFeed.Icon = "news";
Children.Add(navigationNewFeed);
// Volunteer View
var navigationPageVolunteer = new NavigationPage(new VolunteerView());
navigationPageVolunteer.Icon = "Volunteer";
navigationPageVolunteer.Title = "Volunteer";
Children.Add(navigationPageVolunteer);
// LAH View
var navigationPageLAH = new NavigationPage(new LAHView());
navigationPageLAH.Icon = "lah";
navigationPageLAH.Title = "LAH";
Children.Add(navigationPageLAH);
// Notification View
var navigationPageNotification = new NavigationPage(new NotificationView());
navigationPageNotification.Icon = "notification";
navigationPageNotification.Title = "Notification";
Children.Add(navigationPageNotification);
// Account View
var navigationPageAccount = new NavigationPage(new AccountView());
navigationPageAccount.Icon = "account";
navigationPageAccount.Title = "Account";
Children.Add(navigationPageAccount);
}
答案 0 :(得分:1)
您可以使用自定义样式并更改选项卡中的文本大小。 How to use custom style for tab
改变风格:
<style name="CustomTab"
parent="@android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textSize">5sp</item>
</style>
答案 1 :(得分:1)
尝试在Android XF项目中通过In [246]: np.delete(arr[:][:], 1, axis=2).flags
Out[246]:
C_CONTIGUOUS : True
F_CONTIGUOUS : False
OWNDATA : True # <========= Its own copy
WRITEABLE : True
ALIGNED : True
UPDATEIFCOPY : False
设置较小的文字大小,添加 app:tabTextAppearance =&#34;?android:attr / textAppearanceSmall&#34;
Tabbar.axml
答案 2 :(得分:0)
基本上,在android中,该文本按默认 的格式显示在CAPS中,尽管您在大写字母中键入了首字母,在小写中键入了以下单词(例如,“按钮文本”但是,“接受”显示为接受)。
要覆盖它并在您键入(即接受)时显示它,请将此行包含在您应用于Android活动的主题文件中(例如在YourProject.Android/Resources/values/styles.xml中)
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
............
<item name="android:textAllCaps">false</item>
</style>
感谢Why is my Button text forced to ALL CAPS on Lollipop?
中的答案编辑::如果缺少标签标题,则可以使用下面的代码来解决,因为它很好地解决了我的问题!
using Android.Content;
using Android.Support.Design.Internal;
using Android.Views;
using FixedTabbedPage.Droid.CustomRenderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms.Platform.Android.AppCompat;
[assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTabbedPageRenderer))]
namespace FixedTabbedPage.Droid.CustomRenderers
{
public class CustomTabbedPageRenderer : TabbedPageRenderer
{
public CustomTabbedPageRenderer(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
{
base.OnElementChanged(e);
if (ViewGroup != null && ViewGroup.ChildCount > 0)
{
BottomNavigationMenuView bottomNavigationMenuView = FindChildOfType<BottomNavigationMenuView>(ViewGroup);
if (bottomNavigationMenuView != null)
{
var shiftMode = bottomNavigationMenuView.Class.GetDeclaredField("mShiftingMode");
shiftMode.Accessible = true;
shiftMode.SetBoolean(bottomNavigationMenuView, false);
shiftMode.Accessible = false;
shiftMode.Dispose();
for (var i = 0; i < bottomNavigationMenuView.ChildCount; i++)
{
var item = bottomNavigationMenuView.GetChildAt(i) as BottomNavigationItemView;
if (item == null) continue;
item.SetShiftingMode(false);
item.SetChecked(item.ItemData.IsChecked);
}
if (bottomNavigationMenuView.ChildCount > 0) bottomNavigationMenuView.UpdateMenuView();
}
}
}
private T FindChildOfType<T>(ViewGroup viewGroup) where T : Android.Views.View
{
if (viewGroup == null || viewGroup.ChildCount == 0) return null;
for (var i = 0; i < viewGroup.ChildCount; i++)
{
var child = viewGroup.GetChildAt(i);
var typedChild = child as T;
if (typedChild != null) return typedChild;
if (!(child is ViewGroup)) continue;
var result = FindChildOfType<T>(child as ViewGroup);
if (result != null) return result;
}
return null;
}
}
}
2)https://forums.xamarin.com/discussion/comment/361462#Comment_361462
感谢jezh和J.Aguilar
希望这会有所帮助。