2014-12-16 1 views
0

나는이 질문을 여러 번 들었지만 아직도 나는 올바르게 이해하지 못하고있다. 제발 도와주세요. 텍스트 뷰어의 글꼴을 바꾸고 싶습니다. Google에서 코드를 찾아서 끝내겠습니다. 내 XML안드로이드에서 글꼴 바꾸기

<pocketdocs.indiehustlers.com.pocketdocsv2.Utils.SliderFont 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_marginLeft="5dp" 
    android:text="AWAITED APPROVAL" 
    android:textColor="#fff" 
    android:textSize="@dimen/edit_text_size" /> 

코드

public class SliderFont extends TextView { 
    public SliderFont(Context context, AttributeSet attrs) { 
     super(context, attrs); 

     Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/redhead.ttf"); 
     setTypeface(typeface); 
    } 
} 

그리고이 사용을하고하지만 여전히 내가 원하는 글꼴을 받고 있지 않다.

나는 코드에 문제가 was'nt 자산이 enter image description here

+2

가 있습니까 어떤 오류가있어? –

+0

Nah하지만 글꼴도 변경되지 않습니다. – Anuj

+0

여기에 무슨 문제가 있습니까? – Jaydeep

답변

0

처럼 폴더를 생성 한, 그것은 표시되지 그래서 내가 오히려 장치보다 XML 편집기에서 변화를 확인했다 단지이었다.

PS-글꼴 변화는 늘 XML 편집기에서 개최, 당신은

2

대신 에뮬레이터 또는 실제 장치에서 실행해야합니다 :

Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/redhead.ttf"); 
     setTypeface(typeface); 

시도 사용 :

Typeface typeface = Typeface.createFromAsset(getResources().getAssets(), "fonts/redhead.ttf"); 
      yourTv.setTypeface(typeface); 
관련 문제