In this Android tip, I am going to show you how to use Heydings icons font in your application. Using font icons is better than images because the font icons can be scaled without losing quality. You are also easy to change colors, and apply shadow to the font icons.
<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"
tools:context="com.example.myfirstprogram.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="#0B3861"
>
<TextView
android:id="@+id/txtreg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="30sp"
android:textColor="#ffffff"
android:gravity="center"
/>
<TextView
android:id="@+id/txttracking"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="30sp"
android:textColor="#ffffff"
android:gravity="center"
/>
<TextView
android:id="@+id/txtsms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="30sp"
android:textColor="#ffffff"
android:gravity="center"
/>
<TextView
android:id="@+id/txtqa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="30sp"
android:textColor="#ffffff"
android:gravity="center"
/>
</LinearLayout>
</RelativeLayout>
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create Typeface object to use the icons font
Typeface font= Typeface.createFromAsset(getAssets(), "heydings_icons.ttf");
TextView regIcon=(TextView)findViewById(R.id.txtreg);
TextView trackIcon=(TextView)findViewById(R.id.txttracking);
TextView smsIcon=(TextView)findViewById(R.id.txtsms);
TextView qaIcon=(TextView)findViewById(R.id.txtqa);
regIcon.setTypeface(font);
regIcon.setText("\u0041");
trackIcon.setTypeface(font);
trackIcon.setText("\u0040");
smsIcon.setTypeface(font);
smsIcon.setText("\u0045");
qaIcon.setTypeface(font);
qaIcon.setText("\u0051");
}
}
|
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.