我在 ViewPager 使用 PagerTabStrip 来显示每个网页的标题。这里是我的XML code:
I'm using PagerTabStrip in ViewPager to show the title of each page. Here is my XML code:
<RelativeLayout xmlns:android="schemas.android/apk/res/android" xmlns:tools="schemas.android/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg"> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="fill_parent" android:layout_height="fill_parent" > <android.support.v4.view.PagerTabStrip android:id="@+id/pager_title_strip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top" android:background="#33b5e5" android:textColor="#a4c639" android:paddingTop="4dp" android:paddingBottom="4dp" /> </android.support.v4.view.ViewPager> </RelativeLayout>
我想设置的文本样式,以大胆 PagerTabStrip 是这样的: 安卓TEXTSTYLE =黑体。但是,这是不可能的 PagerTabStrip 。好像它只有文本颜色属性的文本。什么是我可以设置风格大胆的方式?
I want to set the textStyle to bold in PagerTabStrip like this: android:textStyle="bold". But this is not possible in PagerTabStrip. Seems like it has only textcolor property for text. What is the way by which I can set the style to bold?
推荐答案您需要做的是创造文本样式,然后使用android:textAppearance属性...
What you need to do is create a style for the text, and then use the android:textAppearance attribute...
也许是这样的:
<style name="PagerTabStripText"> <item name="android:textSize">14sp</item> <item name="android:textStyle">bold</item> <item name="android:textColor">#a4c639</item> </style>
,然后在PagerTabStrip XML做到这一点:
And then in your PagerTabStrip XML do this:
<android.support.v4.view.PagerTabStrip android:id="@+id/pager_title_strip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top" android:background="#33b5e5" android:paddingTop="4dp" android:paddingBottom="4dp" android:textAppearance="@style/PagerTabStripText"/>更多推荐
如何设置PagerTabStrip的文字样式为粗体?
发布评论