저는 구자라트 언어에 대한 뉴스 응용 프로그램을 개발 중입니다. 내 문제는 잘 작동하지만 글꼴 대신 사각형 ([])을 표시하므로 Gujarati 글꼴을 표시 할 수 있도록 구자라트 언어로 표시 할 수 있습니까?Android 앱의 언어를 변경할 수 있습니까?
미리 감사드립니다. 자산 폴더에있는 모든 사본 글꼴의
저는 구자라트 언어에 대한 뉴스 응용 프로그램을 개발 중입니다. 내 문제는 잘 작동하지만 글꼴 대신 사각형 ([])을 표시하므로 Gujarati 글꼴을 표시 할 수 있도록 구자라트 언어로 표시 할 수 있습니까?Android 앱의 언어를 변경할 수 있습니까?
미리 감사드립니다. 자산 폴더에있는 모든 사본 글꼴의
먼저, 다음 다음
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/gujaratifont.otf");
및 쓰기 :
text.setTypeFace(tf);
이 XML을 사용하여 글꼴의 서체를 변경하는 방법입니다. xmlns:your_namespace="http://schemas.android.com/apk/res/com.nound.test"
/고해상도/값/attrs에있는 사용자 지정 특성 (들)을 정의합니다 ("com.nound.test는"Manifest.xml에 정의 된 패키지 이름) :
<resources>
<declare-styleable name="TypefacedTextView">
<attr name="textStyle" format="string"/>
</declare-styleable> </resources>
자바 클래스는 텍스트 뷰를 확장 {
public TypefacedTextView(Context context, AttributeSet attrs) {
super(context, attrs);
//Typeface.createFromAsset doesn't work in the layout editor. Skipping...
if (isInEditMode()) {
return;
}
TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.TypefacedTextView);
//String fontName = styledAttrs.getString(R.styleable.TypefacedTextView_typeface);
String fontNameForBold = styledAttrs.getString(R.styleable.TypefacedTextView_textStyle);
styledAttrs.recycle();
if (fontNameForBold!=null && fontNameForBold.equals("bold")) {
Typeface typeface_bold = Typeface.createFromAsset(context.getAssets(), "fonts/tahoma/tahoma_bold.ttf");
setTypeface(typeface_bold);
}else{
Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/tahoma/tahoma.ttf");
setTypeface(typeface);
}
}
다음은 글꼴의 서체를 변경 싶어 레이아웃 코드입니다. 이 "com.nound.test.ui"의 위 (3 점) java 파일 패키지 이름입니다. TypefacedTextView는 클래스 이름입니다.
<com.nound.test.ui.TypefacedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:your_namespace="http://schemas.android.com/apk/res/com.nound.test"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Custom fonts in XML are easy_bold font"
your_namespace:textStyle="bold" />
<com.nound.test.ui.TypefacedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:your_namespace="http://schemas.android.com/apk/res/com.nound.test"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Custom fonts in XML are easy_regular font"
/>
의 할 정도로 ...
당신이 구자라트어의 글꼴 파일이? – Akhil
예 .ttf 파일이 있습니다. –