我读过这个:
还有更多的链接,我已经弄清楚什么是StackedBackground以及什么是Background,但我找不到如何从Tabs中删除All Caps并获得常规字体,或者在操作栏标签中更改字体大小.
除此之外,我喜欢改变我的蓝色下划线的颜色,如果我使用9个补丁图形,我得到的情况与上面的链接相似,我的行在文本下面,但不在下面的标签底部,并且原来的蓝线仍然存在,所以我得到两条线.
到目前为止,我有这个,但我已经尝试了文字大小和各种颜色,但没有:
<style name="CustomActivityTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/grey</item>
<item name="android:backgroundStacked">@drawable/ab_transparent_example</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">10dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
编辑:我只是发现我可以使用"android:actionBarTabTextStyle"删除所有大写字母,但它现在需要"MyActionBar"的背景颜色...所以如何在某些层次结构中设置actionBarTabTextStyle和actionBarStyle列表,该文本缩小了尺寸而不是在Caps中,但它不是"MyActionBar"风格的背景.
编辑2:我已经尝试了一些更多9patch图像,它看起来很丑,但我无法摆脱蓝线......

我问过几次这个任务,但我没有解决方案:(我的问题是,我有一个带有标签活动的Android应用程序,我必须设置我的标签的字体大小,但我不知道怎么样.
在我的活动中,我以编程方式设置我的标签:
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("MY TAB 1"));
tabLayout.addTab(tabLayout.newTab().setText("MY TAB 2"));
tabLayout.addTab(tabLayout.newTab().setText("MY TAB 3"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
Run Code Online (Sandbox Code Playgroud)
问题是,最后的1 - 2个字母将被剪切,所以我必须设置较小的字体大小,但如何?
我希望有人能帮助我.
我一直在标签栏中遇到文字大小的问题。下面是图片,

这是我的代码,
public class MainActivity extends Activity implements OnTabChangeListener, OnPageChangeListener{
private TabHost tabHost;
private ViewPager pager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tabHost = (TabHost)findViewById(android.R.id.tabhost);
pager = (ViewPager) findViewById(R.id.pager);
tabHost.setup();
TabWidget tabwidget=tabHost.getTabWidget();
TabSpec spec = tabHost.newTabSpec("tab1");
spec.setContent(R.id.tab1);
spec.setIndicator("Check In");
tabHost.addTab(spec);
spec = tabHost.newTabSpec("tab2");
spec.setContent(R.id.tab2);
spec.setIndicator("Buddies");
tabHost.addTab(spec);
spec = tabHost.newTabSpec("tab3");
spec.setContent(R.id.tab3);
spec.setIndicator("Recommendation");
tabHost.addTab(spec);
spec = tabHost.newTabSpec("tab4");
spec.setContent(R.id.tab4);
spec.setIndicator("Feed");
tabHost.addTab(spec);
spec = tabHost.newTabSpec("tab5");
spec.setContent(R.id.tab5);
spec.setIndicator("Last");
tabHost.addTab(spec);
pager.setAdapter(new MyPagerAdapter(this));
pager.setOnPageChangeListener(this);
tabHost.setOnTabChangedListener(this);
}
@Override
public void onTabChanged(String tabId){
int pageNumber = …Run Code Online (Sandbox Code Playgroud) 如何使用书法将自定义字体应用于设计支持库中的TabLayout?
我已经得到它在Java工作,大多数答案似乎参考.(例如,在Android设计支持TabLayout中更改选项卡文本的字体)
我不想做自定义课程,我只想使用书法.(https://github.com/chrisjenx/Calligraphy)
谢谢
我想在设计支持库的tablayout中嵌入自定义字体.我尝试设置已设置字体的自定义视图.但它没有用.只是出现系统字体.
我做的是,
mAdpater = new CustomPagerAdapter(getSupportFragmentManager());
mFragmentPager.setAdapter(mAdpater);
mTabs.setupWithViewPager(mFragmentPager);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/myFont.ttf");
for (int i = 0; i < mTabs.getTabCount(); i++) {
TextView tv = new TextView(this);
tv.setText(mAdpater.getPageTitle(i));
tv.setTypeface(tf);
mTabs.getTabAt(i).setCustomView(tv);
}
Run Code Online (Sandbox Code Playgroud)
欢迎任何建议.
如何删除工具栏和tablayout之间的深线,我搜索谷歌有人说,添加一些高度到工具栏和tablayout,我做但但它没有工作,从工具栏中删除高程和tablyout后,它也无法正常工作.请帮帮我:
tablayout_xml:
<RelativeLayout
android:id="@+id/main_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
app:tabGravity="fill"
android:elevation="2dp"
app:tabMode="fixed"
app:font="Nexa Bold.otf"
android:minHeight="?attr/actionBarSize"
android:background="@color/appbarColor"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/tab_layout"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
activity_toolbar:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/container_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/appbarColor"
android:elevation="2dp"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/_15sdp"
android:textStyle="bold"
android:textColor="#fff"
android:layout_gravity="center"
android:id="@+id/toolbar_title" />
<LinearLayout
android:id="@+id/clearllBtn"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginRight="5dp"
android:layout_gravity="right"
android:visibility="gone"
android:background="@drawable/toolbar_ripple"
android:gravity="center_vertical|center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/appbar_txt_size" …Run Code Online (Sandbox Code Playgroud) 我在一个片段中使用选项卡视图。
我想在使用书法时更改字体,这是链接:书法
除了选项卡视图,我可以在整个应用程序中更改字体。
该类的代码在这里,如果您能解决问题,
我真的很感激,我被困在这里。
这是我的代码:
public class AsliFragment extends Fragment {
@SuppressLint("StaticFieldLeak")
public static ViewPager viewPager;
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
public AsliFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
getArguments().getString(ARG_PARAM1);
getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for …Run Code Online (Sandbox Code Playgroud)