이 같은 tabTextStyle을 설정하는 것이
<style name="TabTextStyle" parent="@style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">@android:color/holo_blue_bright</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">bold</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
같은 새로운 탭 텍스트 스타일을 정의하여 탭의 텍스트 스타일을 사용자 정의 할 수 있습니다하는 것은 정의를 사용하는 코드입니다 작업 표시 줄의 텍스트 :
ActionBar act = ((ActionBarActivity) getActivity()).getSupportActionBar();
LayoutInflater inflator = LayoutInflater.from(getActivity());
View v = inflator.inflate(R.layout.action_bar_custom, null);
((MyCustomTextView) v.findViewById(R.id.title_text)).setText(title);
act.setCustomView(v);
이 경우 Google은 사용자 정의 TextView
을 ormal 레이아웃 우리가 ActionBar
에서보기로 설정할 팽창, 레이아웃은 다음과 같이 표시됩니다
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ch.nuewsli.widget.TestoTextView
android:id="@+id/title_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/WHITE_TEXTCOLOR"
android:textSize="18sp"
android:lines="1"
android:gravity="center_vertical"/>
</LinearLayout>
를 당신이해야하는 XML에서 ActionBar
글꼴 (만 폰트 패밀리를) 변경할 수 없습니다 때문에 TextView
을 확장하고 글꼴을 사용하고 글꼴을 ActionBar
에 넣으려면 글꼴을 assets
폴더로 복사해야합니다. 아래 코드는 android:textStyle
속성에 지정된 TextView
의 스타일을 bold
과 다른 스타일로 구별 할 수 있습니다. 내가 그렇지 않으면 당신은 사용자 정의 글꼴을 사용할 수 없기 때문에 내가 필요가 있다고 생각
public MyTextView(Context context, AttributeSet attrs, int defStyle) {
this(context, attrs);
}
public MyTextView(Context context) {
super(context);
this.mContext = context;
init();
}
public void init() {
Typeface typeface = getTypeface();
if(typeface != null)
style = typeface.getStyle();
if(style != Typeface.BOLD) {
typeface = Typeface.createFromAsset(mContext.getAssets(), "My-Font-Regular.ttf");
}else {
typeface = Typeface.createFromAsset(mContext.getAssets(), "My-Font-Bold.ttf");
}
this.setTypeface(typeface);
}
:
UPDATE 은 그냥
TextView
의 코드를 삽입. – Nuno내 생각에 사용자 정의보기를 사용해 보셨습니까? http://developer.android.com/reference/android/app/ActionBar.Tab.html#setCustomView(android.view.View) 및 http://stackoverflow.com/questions/17893664/how-to-customize- 액션 바 바 탭 – nenne
예, 그런 글꼴을 바꿀 수는 있지만 내가 한 모든 다른 커스터마이징을 잃을 것입니다. – Nuno