相关疑难解决方法(0)

如何将PagerTabStrip的TextStyle设置为Bold?

我正在使用PagerTabStripViewPager来显示每个页面的标题.这是我的XML代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/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>
Run Code Online (Sandbox Code Playgroud)

我想将textStyle设置为粗体,PagerTabStrip如下所示: android:textStyle="bold".但这是不可能的PagerTabStrip.好像它只有textcolor文本属性.我可以将样式设置为粗体的方式是什么?

android styles android-viewpager

17
推荐指数
1
解决办法
2万
查看次数

如何将TypeFace设置为PagerTabStrip文本视图

在我的应用程序中,我正在使用带有PagerTabStripViewPager,我需要将自定义字体设置为我的小部件.要为a Button或a 设置字体,TextView我只需扩展类并设置字体.

public class MyButton extends Button {

    public MyButton(Context context) {
        super(context);
        initCustomFont();
    }

    public MyButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        initCustomFont();
    }

    public MyButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initCustomFont();
    }

    private void initCustomFont() {
        if(!isInEditMode()) {
            Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/boton_regular.ttf");
            setTypeface(tf);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但我不能用这种方法PagerTabStrip.有没有其他方法来设置可以使用的字体PagerTabStrip

android custom-font

4
推荐指数
1
解决办法
3810
查看次数

标签 统计

android ×2

android-viewpager ×1

custom-font ×1

styles ×1