2014-01-29 4 views
0

나는이 사용자 정의 글꼴을 (Kulturista Bold. ttf) 추가하려고하는데 안드로이드 응용 프로그램을 개발했지만 작동하지 않습니다. 여기에 내 login.xml 파일과 login.java가 있습니다. 파일안드로이드 액티비티에 새 글꼴을 추가하는 방법

<TextView 
       android:id="@+id/maintitle" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="CREATE AN ACCOUNT?" 
       android:textColor="@color/blue" 
       android:textSize="25dp" 
       android:layout_gravity="center" 
        android:layout_marginTop="70dp" 
       android:gravity="center"/> 
     <TextView 
      android:id="@+id/subtitle" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="CLICK ON THE SIGHNUP AND REGISTER" 
      android:textColor="#c4cbcf" 
      android:layout_gravity="center" 
      android:gravity="center" 
      /> 

이 벗기는하여이 작업을 시도

//Space between dot(.) and ttf Kulturista_Bold. ttf 
Typeface font1 = Typeface.createFromAsset(getAssets(), "Kulturista_Bold. ttf"); 

"ttf 글꼴."활동 코드를에서

protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.login); 
     TextView txt1 = (TextView) findViewById(R.id.maintitle); 
     Typeface font1 = Typeface.createFromAsset(getAssets(), "Kulturista_Bold. ttf"); 
     txt1.setTypeface(font1); 
     TextView txt2 = (TextView) findViewById(R.id.subtitle); 
     Typeface font2 = Typeface.createFromAsset(getAssets(), "Kulturista_Bold. ttf"); 
     txt2.setTypeface(font2); 
    } 

} 
+0

과 같은 사용자 글꼴은이 'Kulturista_Bold와 같은 저작물 폴더와 같습니다. ttf' 한 번 이름을 확인해 보라.'Kulturista_Bold.ttf' – NagarjunaReddy

+0

'ttf' 파일은 어디에 있습니까? 자산 폴더에 있습니까? –

답변

0

제거 공간 g 공간.

Typeface font1 = Typeface.createFromAsset(getAssets(), "Kulturista_Bold.ttf"); 
+0

작동하지 않습니다. – user3021253

0

시도 getContext 또는 activityName를 추가 getAssets 전에 : 당신이에서 액세스 할 수있는 경우

Typeface font = Typeface.createFromAsset(getContext(),"fonts/androidnation.ttf"); 

또는

Typeface font = Typeface.createFromAsset(activityname.this.getAssets(), "fonts/androidnation.ttf"); 

txt1.setTypeface(font); 
-1

Typeface typeFace = Typeface.createFromAsset(getAssets(), "Kulturista_Bold.ttf"); 
txt2.setTypeface(typeFace); 
1

시도 애셋 폴더 만 코드에 입력하면 에서 공간이 삭제됩니다. TTF

는 그래서

Typeface font1 = Typeface.createFromAsset(getAssets(), "Kulturista_Bold.ttf"); 

다음으로 액세스 할 필요는 자산 폴더에 폴더라는 이름의 글꼴을 만든 경우 변경합니다.

Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/Kulturista_Bold.ttf"); 
관련 문제