如何设置PagerTabStrip的文字样式为粗体?

编程入门 行业动态 更新时间:2024-10-11 13:19:59
本文介绍了如何设置PagerTabStrip的文字样式为粗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在 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的文字样式为粗体?

本文发布于:2023-10-19 18:51:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1508444.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:样式   粗体   如何设置   文字   PagerTabStrip

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!