2011-06-24 17 views
5

मैं उस एप्लिकेशन में एंड्रॉइड 2.2 में एक एप्लिकेशन बना रहा हूं मैं एंड्रॉइड एप्लिकेशन में टेक्स्ट व्यू में हिंदी टेक्स्ट दिखाना चाहता हूं। (कैसे पाठ दृश्य में जोड़ने के लिए "मैं छात्र हूँ" शब्द)एंड्रॉइड एप्लिकेशन में फ़ॉन्ट कैसे जोड़ें

कृपया मेरी मदद करो ..

+0

संभावित डुप्लिकेट [एंड्रॉइड एप्लाका में बाहरी फ़ॉन्ट कैसे जोड़ें tion।] (http://stackoverflow.com/questions/5634245/how-to-add-external-fonts-to-android- appplication) –

उत्तर

17

अपनी परियोजना में संपत्ति फ़ोल्डर में अपने फ़ॉन्ट जोड़ें और का उपयोग नीचे झलकी

TextView hindiTextView=(TextView)findViewById(R.id.txtbx); 
Typeface hindiFont=Typeface.createFromAsset(getAssets(),"fonts/fontname.ttf"); 
mytextView.setTypeface(hindiFont); 

इसकी आशा उपयोगी।

+0

धन्यवाद इसके काम ... –

+0

यह काम नहीं कर रहा है, केवल आयताकार बक्से दिखा रहा है, मैं vigyapti.ttf फ़ाइल –

+0

फ़ॉन्ट फ़ोल्डर पर त्रुटि दिखा रहा है .. फ़ॉन्ट फ़ोल्डर को शामिल करने के लिए .. मैं संसाधन फ़ोल्डर – Giridharan

3

1) जोड़ें "फोंट" फोंट के अंदर "संपत्ति" फ़ोल्डर और पेस्ट फॉन्ट के अंदर फ़ोल्डर लेआउट फ़ाइल में फ़ोल्डर

2):

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
     > 

    <TextView 
      android:id="@+id/custom_font" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="मैं छात्र हूँ" 
      /> 

3) गतिविधि जहां में आप पाठ को नीचे दिए गए कोड का उपयोग करना चाहते हैं:

TextView txt = (TextView) findViewById(R.id.custom_font); 
Typeface font = Typeface.createFromAsset(getAssets(), "hindifont.ttf"); 
txt.setTypeface(font);