Android   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 在Sherlock ActionBar选项卡视图中将标题文本大小写更改为小写大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我使用Sherlock ActionBar Tab Views创建了一个标签应用程序.我喜欢将Tab标题更改为小写.看屏幕截图

我想将TAB1更改为tab1

非常感谢任何解决方

我的代码如下

public class MainActivity extends SherlockFragmentActivity {

// Declare Variables
ActionBar mActionBar;
ViewPager mPager;
Tab tab;

@Override
protected void onCreate(Bundle savedInstanceStatE) {
    super.onCreate(savedInstanceStatE);
    // Get the view from activity_main.xml
    setContentView(R.layout.activity_main);

    // Activate Navigation Mode Tabs
    mActionBar = getSupportActionBar();
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Locate ViewPager in activity_main.xml
    mPager = (ViewPager) findViewById(R.id.pager);

    // Activate Fragment Manager
    FragmentManager fm = getSupportFragmentManager();

    // Capture ViewPager page swipes
    ViewPager.SimpLeonPagechangelistener ViewPagerListener = new ViewPager.SimpLeonPagechangelistener() {
        @Override
        public void onPageSELEcted(int position) {
            super.onPageSELEcted(position);
            // Find the ViewPager Position
            mActionBar.setSELEctedNavigationItem(position);
        }
    };

    mPager.setOnPagechangelistener(ViewPagerListener);
    // Locate the adapter class called ViewPagerAdapter.java
    ViewPagerAdapter viewpageradapter = new ViewPagerAdapter(fm);
    // Set the View Pager Adapter into ViewPager
    mPager.setAdapter(viewpageradapter);

    // Capture tab button clicks
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {

        @Override
        public void onTabSELEcted(Tab tab, Fragmenttransaction ft) {
            // Pass the position on tab click to ViewPager
            mPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnSELEcted(Tab tab, Fragmenttransaction ft) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onTabReSELEcted(Tab tab, Fragmenttransaction ft) {
            // TODO Auto-generated method stub
        }
    };

    // Create first Tab
    tab = mActionBar.newTab().setText("Tab1").setTabListener(tabListener);
    mActionBar.addTab(tab);

    // Create second Tab
    tab = mActionBar.newTab().setText("Tab2").setTabListener(tabListener);
    mActionBar.addTab(tab);

    // Create third Tab
    tab = mActionBar.newTab().setText("Tab3").setTabListener(tabListener);
    mActionBar.addTab(tab);

 }

谢谢

解决方法:

在styles.xml中为Tablayout添加样式

<style name="TabTextAppearance" parent="TextAppearance.Design.Tab">
    <item name="textAllCaps">false</item>
</style>

然后将该属性添加为:

<android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        app:tabTextAppearance="@style/TabTextAppearance"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

我测试了它.它会工作的.

大佬总结

以上是大佬教程为你收集整理的android – 在Sherlock ActionBar选项卡视图中将标题文本大小写更改为小写全部内容,希望文章能够帮你解决android – 在Sherlock ActionBar选项卡视图中将标题文本大小写更改为小写所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: