[英]How to increase the android action bar tabs text size
I used TabsPagerAdapter and ViewPager to implement tabs in my action bar. 我使用TabsPagerAdapter和ViewPager在操作栏中实现选项卡。 I did it but my problem is tabs text is showing small size in tablets(tvdpi device).
我做到了,但是我的问题是标签文本在平板电脑(tvdpi设备)中显示为小尺寸。 Can u please tell me how to increase tabs text size.
您能告诉我如何增加制表符的文本大小吗?
Thank you. 谢谢。
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
ActionBar actionBar = getSupportActionBar();
TabsPagerAdapter mAdapter = new TabsPagerAdapter(getSupportFragmentManager(),
getIntent().getBundleExtra("rechargeInfo"));
viewPager.setAdapter(mAdapter);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
//Adding Tabs
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name)
.setTabListener(this));
}
/**
* on swiping the viewpager make respective tab selected
* */
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
@Override
public void onTabReselected(Tab arg0, FragmentTransaction arg1) {
// TODO Auto-generated method stub
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction arg1) {
// TODO Auto-generated method stub
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(Tab arg0, FragmentTransaction arg1) {
// TODO Auto-generated method stub
}
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import com.amulyam.users.BalanceFragment;
import com.amulyam.users.RechargeActivity;
import com.amulyam.users.SpecialOffersFragment;
public class TabsPagerAdapter extends FragmentStatePagerAdapter {
private Bundle rechargeInfo;
public TabsPagerAdapter(FragmentManager fm, Bundle rechargeInfo) {
super(fm);
this.rechargeInfo = rechargeInfo;
}
@Override
public Fragment getItem(int index) {
switch (index) {
case 0:
// Special Offers fragment activity
return new SpecialOffersFragment();
case 1:
// Balance fragment activity
return new BalanceFragment();
case 2:
// Recharge fragment activity
RechargeActivity rechargeActivity = new RechargeActivity();
rechargeActivity.setArguments(rechargeInfo);
return rechargeActivity;
}
return null;
}
@Override
public int getCount() {
// get item count - equal to number of tabs
return 3;
}
}
try this.. it would help you 试试这个..它将帮助您
TextView x = (TextView) tabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title);
x.setTextSize(25);
I think you ment you are using swipe tabs. 我想您说您正在使用滑动标签。 if that is what you ment then you can go to the pager layout and inside the android.support.v4.view.PagerTitleStrip write android:textSize="xxsp" where xx is the size you want.
如果您要这么做,则可以转到传呼机布局,然后在android.support.v4.view.PagerTitleStrip中写入android:textSize =“ xxsp”,其中xx是您想要的大小。 for example I did it like so:
例如,我这样做是这样的:
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/pager"
android:layout_height="match_parent">
<android.support.v4.view.PagerTitleStrip
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/title"
android:layout_gravity="top"
android:textSize="25sp"
>
</android.support.v4.view.PagerTitleStrip>
</android.support.v4.view.ViewPager>
and you can do the same for the color and backgrounds: android:textColor="@color/black"
并且您可以对颜色和背景进行相同操作:
android:textColor="@color/black"
Hope this will help you 希望这个能对您有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.