Demo:
Devices =>
2.3 & 4.2
1)MainActivity.java:
2)activity_main.xml:
Download shruti.ttf file and put into asset folder
For Download ttf file Click Here
Devices =>
2.3 & 4.2
1)MainActivity.java:
package
com.venky.displaygujaratifont;
import
android.app.Activity;
import
android.graphics.Typeface;
import
android.os.Bundle;
import
android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tvGujarati = (TextView)
findViewById(R.id.tvGujarati);
TextView tvEnglish = (TextView)
findViewById(R.id.tvEnglish);
tvEnglish.setText("In
English\n" + "Welcome");
Typeface faceShruti = Typeface.createFromAsset(getAssets(),
"shruti.ttf");
tvGujarati.setTypeface(faceShruti);
tvGujarati.setText("In
Gujarati\n" + "સ્વાગત");
}
}
2)activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#5F04B4"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
>
<TextView
android:id="@+id/tvEnglish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="51dp"
android:text="text1"
android:textColor="#ffffff"
android:textSize="20dp"
/>
<TextView
android:id="@+id/tvGujarati"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvEnglish"
android:layout_below="@+id/tvEnglish"
android:layout_marginTop="66dp"
android:text="text2"
android:textColor="#ffffff"
android:textSize="20dp"
android:textStyle="bold"
/>
</RelativeLayout>
3)TTF file:
Download shruti.ttf file and put into asset folder
For Download ttf file Click Here
4)Download this code Click Here
thank you it is helpful for me and my group
ReplyDeleteI don't have asset package in my android project. What to do
ReplyDeletenice sharing. waiting for your next post. Happy Blogging :)
ReplyDeleteJanva Jevu In Gujarati