내 앱에서 PagerTabStrip으로 ViewPager을 사용하고 있으며 내 위젯에 맞춤 글꼴을 설정해야합니다. 글꼴을 Button
또는 TextView
으로 설정하려면 클래스를 확장하고 서체를 설정하면됩니다.TypeFace를 PagerTabStrip 텍스트 뷰로 설정하는 방법
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);
}
}
}
그러나이 방법은 PagerTabStrip
에 사용할 수 없습니다. PagerTabStrip
과 함께 사용할 수있는 서체를 설정하는 다른 방법이 있습니까?
이것은 가능한 가장 빠른 해결책 일 수 있습니다. 감사합니다.) – ben
동의하지만 다른 소스 코드를 직접 잡아서 수정하는 것 외에는 다른 해결책을 생각할 수 없습니다. PagerTabStrip의 서체를 직접 변경할 수있는 API는 없습니다. – StackOverflower