如何像我在android中希望的那样以小写形式设置选项卡名称
我正在开发一个包含三个片段选项卡的屏幕。选项卡标题只有大写的第一个字母:如何像我在android中希望的那样以小写形式设置选项卡名称,android,tabs,Android,Tabs,我正在开发一个包含三个片段选项卡的屏幕。选项卡标题只有大写的第一个字母: private String[] tabs = { "About Me", "Education","ProfileEdit"}; 但当我运行应用程序时,标题都是大写的 如何使选项卡正确显示单词 选项卡设置代码: private String[] tabs = { "About Me", "Education","ProfileEdit"}; @Override protected void onCreate(B
private String[] tabs = { "About Me", "Education","ProfileEdit"};
但当我运行应用程序时,标题都是大写的
如何使选项卡正确显示单词
选项卡设置代码:
private String[] tabs = { "About Me", "Education","ProfileEdit"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.editprofile);
user=(UserModel)getIntent().getSerializableExtra("USER");
// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(true);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Adding Tabs
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name.toLowerCase())
.setTabListener(this));
}
/**
* on swiping the viewpager make respective tab selected
* */
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// on changing the page
// make respected tab selected
actionBar.setSelectedNavigationItem(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
更新
我用textAllCaps false编辑了主题,但文字显示方式相同:
<resources>
<style name="MyTheme" parent="Theme.Sherlock">
<item name="actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
<item name="android:actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
</style>
<style name="MyMenuTextAppearance" parent="TextAppearance.Sherlock.Widget.ActionBar.Menu">
<item name="android:textAllCaps">false</item>
</style>
@样式/MyMenuTextAppearance
@样式/MyMenuTextAppearance
假的
Android 4.0中选项卡视图的默认主题(Holo主题)将Android:textAllCaps设置为true。 见:
在styles.xml中为表格布局添加样式
<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.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="@android:color/white"
app:tabIndicatorHeight="2dp"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
app:tabSelectedTextColor="@android:color/white"
app:tabTextColor="@android:color/white" />
可能重复@PedroOliveira…先生,我无法从开发人员Guid获得有关我的解决方案的信息@ツ爱上机器人ツ 先生,我正在使用Actionbar sherlock主题,你能告诉我在哪里编辑吗?我正在使用Actionbar sherlock主题,你能告诉我如何设置False吗?以后应该用大写字母。不是全部用小写字母。我按照答案回答了。但是我的标签名全部用小写字母谢谢!这就是您想要的新API,与原来的articleThans vinay相比:当我将样式更改为app:tabTextAppearance=“@style/tabTextAppearance”时,它起到了作用