制表位标题文本以大写字母出现,小写字母出现在此>>

问题描述 投票:0回答:2

我使用了this库,并且其标题文本以我引用的大写形式显示

 <style name="AppTheme" parent="@style/Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:textColorPrimary">@color/text_color</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="android:actionBarTabTextStyle">@style/tab</item>
    <item name="actionBarTabTextStyle">@style/tab</item>

    <item name="android:windowBackground">@color/window_background</item>
    <item name="colorControlNormal">@color/accent</item>
    <item name="colorControlActivated">@color/secondary_text</item>
    <item name="colorControlHighlight">@color/secondary_text</item>
    <item name="android:homeAsUpIndicator">@drawable/ic_menu</item>

</style>

<style name="tab" parent="@style/Widget.AppCompat.Light.ActionBar.TabText">
    <item name="android:textAllCaps">false</item>
</style>

fragment.java:

    tabHost = (MaterialTabHost) v.findViewById(R.id.tabHost);
    adapter = new TabsPagerAdapter(getChildFragmentManager(), entity);
    pager = (ViewPager) v.findViewById(R.id.pager_entitiy_detail);
    pager.setOffscreenPageLimit(adapter.getCount());
    pager.setAdapter(adapter);
    adapter.notifyDataSetChanged();
    pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            tabHost.setSelectedNavigationItem(position);
            Log.e("DashDetail", "");
        }
    });

    // insert all tabs from pagerAdapter data
    for (int i = 0; i < adapter.getCount(); i++) {
        tabHost.addTab(
                tabHost.newTab()
                        .setText(adapter.getPageTitle(i))
                        .setTabListener(this)
        );

    }

上面的代码用于制表符主机和适配器设置文本,但未获取小写字母。

我已经使用了这个库,并且其标题文本以大写形式显示,我已经将此引用,但是没有得到正确的输出。

android title android-tabhost uppercase
2个回答
1
投票
尝试在添加forloop tabs中尝试此操作>>

尝试一下

TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); tv.setAllCaps(false);


1
投票
谢谢,我已经做了上面建议的回答,但是仍然没有用,所以我通过检查代码并对其进行了分析,对库进行了更改。并且我发现这里提到了.toUpperCase(),我从那里删除了它并且起作用了。
© www.soinside.com 2019 - 2024. All rights reserved.