2013-04-24 3 views
9

굴림 글꼴로 텍스트를 표시하고 싶습니다. 그러나 Arial 글꼴은 안드로이드 시스템 글꼴에서 사용할 수 없습니다. 내 응용 프로그램에서 arial ttf 파일을 사용하고 싶지 않습니다. 굴림 글꼴로 텍스트를 적용하는 다른 방법이 있습니까?안드로이드에서의 텍스트 용 굴림 글꼴

+3

Nope. 본질적으로 사용할 수없는 글꼴은'.ttf' /'.otf'가 필요합니다. –

+0

ttf 파일을 내 응용 프로그램에 직접 사용할 수 있습니까? 라이센스 문제가 있습니까? – Keerthi

+5

모든 글꼴이 상업적 목적으로 사용되는 것은 아닙니다. 따라서 사용하기 전에 반드시 확인하십시오. 즉, 나는 항상 프리웨어 글꼴의 거대한 수집이있는 http://www.fontsquirrel.com/으로 향한다. 죄송합니다보다 더 안전. ;-) Arial 글꼴의 라이센스에 대해서는 Wikipedia의 다음 링크를 확인하십시오. http://en.wikipedia.org/wiki/Arial#Free_alternatives –

답변

9

안드로이드 시스템에서 글꼴을 사용할 수없는 경우 폰트 파일을 사용하여 textView에 arial이라는 특정 글꼴을 적용해야합니다. 동일한 기능을 제공 할 때 글꼴 파일을 사용하여 기꺼이 적용하지 않는 이유를 알고 싶습니다. 글꼴 파일을 사용하는

샘플 사용법은 다음과 같습니다

Typeface tfArial = Typeface.createFromAsset(getAssets(), "arial.ttf"); 
TextView tv = null; 
// find the textview id from layout or create dynamically 
tv.setTypeface(tfArial); 

편집 :

당신은 당신의 asset 폴더에있는 글꼴 파일 arial.ttf을 넣어해야합니다.

+0

응용 프로그램에서 Arial 글꼴을 사용해야합니다. – AndroidEnthusiastic

4

다운로드 굴림 글꼴 및 자산는 "글꼴"로 폴더 이름을 생성하고 안드로이드 응용 프로그램에서 사용자 정의 글꼴을 가지고 서예를 사용하는 것을 고려가

Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/arial.ttf"); 
TextView tv = (TextView) findViewById(R.id.CustomFontText); 
tv.setTypeface(tf); 
0

에서 글꼴을 저장합니다.

각 TextView에 코드를 추가하여 글꼴을 적용 할 필요가 없습니다. 응용 프로그램 시작시 간단하게 초기화하면 좋은 것입니다.

0

이 ID에 대한 TabLayout 체크하면 코드에서

다음 사용자 지정 텍스트 뷰를 사용하면 있기 때문에 여기로 ID를 유지해야합니다이

<?xml version="1.0" encoding="utf-8"?> 
<TextView 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@android:id/text1" 
android:layout_width="match_parent" 
android:textSize="15sp" 
android:textColor="@color/tabs_default_color" 
android:gravity="center" 
android:layout_height="match_parent" 
/> 

같은 자바 코드에서 텍스트 뷰 또는 XML 만들기 이 레이아웃을 부풀게하고 해당 텍스트 뷰에 사용자 정의 Typeface을 설정하고 탭에이 사용자 정의보기를 추가하십시오.

for (int i = 0; i < tabLayout.getTabCount(); i++) { 
    //noinspection ConstantConditions 
TextView tv=(TextView)LayoutInflater.from(this).inflate(R.layout.custom_tab,null) 
tv.setTypeface(Typeface);  
tabLayout.getTabAt(i).setCustomView(tv); 

}