Monday 29 October 2012

How to use custom font and style android

How to use custom font and style android
  • How to set custom Font face in android.
  • How to change font of the TextView
  • Set Font run time in android.
  • How to change Font face run time in android.  
  • Setting Font face of TextView,EditText in android.
  • Download free android tutorial for how to set Font face.
  • Android setting font face run time example code.



           This is a simple tutorial for android beginner which will help you to understand how to use custom fonts in your android app.

Android allows user to set Fonts in easier way.

But there is one limitation that you can't set font face using xml, you must need to set font face using code(run time).

You can set Font face of TextView as well as EditText run time.

Steps to set custom fonts in android.
  • Create one TextView  using xml.
    <TextView
    android:id="@+id/tv_example"
    android:text="gtu mca"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >


  • Give reference in java code
     TextView tvExample = (TextVi1ew)findViewById(R.id.
    tv_example);
     
  •  Put Font face file in your assets folder
     
    find from below sample code Fiance.otf
     
  • Create and Initialize object of TypeFace from assets folder 
    Typeface font = Typeface.createFromAsset(getAssets(),Fiance.otf");
     
  • Set Font face to TextView
    tvExample
    .setTypeface(font);
     
  • Build and run your project.
     
  • Here you goes...
GTU MCA Custom Font Demo Download For Free - Free Android Tutorial
 

Related Links  
  1. Get number of lines lines of TextView in Android.
  2. How to create simple TextView in android.
  3. Latest IT news updates 

Sunday 28 October 2012

Difference between AsyncTask and Thread

Different between AsyncTask and Thread in Android  
  • What is Thread ?
    • Thread is a small part of process.
    • Generally we are using thread when we want to perform more than one task at a time.
    • In Java programming thread is a in build facility so it is easy to implement and use thread in android.
    • Java/ Android also supports multi-threading
    • There are two ways of implementing Threads.
      1. Direct an instance of class named Thread
        i.e. java.lang.Thread
      2. By using Runnable interface
        public class RunnableThread implements Runnable
    • Life cycle of Thread
      New -> Runnable -> Running -> Waiting/Blocked/Sleeping
      .
 
  • What is AsyncTask ?
    • AsyncTask is a combination of Thread and Runnable that enable background processing that will allow you to publish result without manipulated Thread and Handler.
    • AsyncTask will started using execute() method.
    • Use of AsyncTask
      1. While loading image from URL.
      2. Performing parsing.
      3. Want to display some process is going on.
      4. etc..
    • Flow of Asynctask execution onPreExecute() -> doInBackground() -> onPostExecute()
  • Difference between AsyncTask and Thread
    Asynctask Thread
  •  

    Saturday 27 October 2012

    Custom intermediate Progress bar in android

    Intermediate Progress Bar


            Android custom intermediate progress bar demo tutorial.
    This tutorial describes how to use custom progress bar in android.
  • Custom intermediate progress bar in android.
  • Custom progress bar in android.
  • Android progress bar loading.
  • How to use custom progress bar in android.
  • Custom progress bar demo in android.
  • Intermediate progress bar in android.
  • Progress bar like iOS/iPhone in android.
  • Free intermediate progress bar demo download.
  • Download free android tutorial with complete source code.
  • Android example code download for free.

  •         This is simple progress bar demo that will show you how to use
    progress bar in android.

            You can also use intermediate progress progress bar in android that
    will show you continuous animation with no progress
    GTU MCA android Custom Intermediate progress bar download
    Related links
    1. How to install android in your pc
    2. How to use 9patch(nine patch)image in android ?
    3. Edit text demo in android
    4. Android - IDE(AIDE) let you allow to develop android application without PC or eclipse.
    5. Android mobile hidden tricks and tips, android hidden codes.
    6. How to use shared preference in android.

    Tuesday 23 October 2012

    android use 9 patch image

    How to use Nine Patch (9 patch) image in android ?

    Whenever you are making android application and planning to include your own custom graphic element. 

    You often face problem of aliasing effect or the image you made is not the same size, resolution problem etc. 

    The solution to those kind of problem is making your custom graphic image into 9 patch PNG file. 
    And android have its own class for making draw9patch.

       

    What is 9 Patch class?
    A nine patch image class permits drawing bitmap in nine sections. 

    • The four corners are unscaled.
    • Four edges are scaled in one axis.
    • The middle is scaled in both axes.

    Normally, the middle is transparent so that the patch can provide a selection about a rectangle. 
    Essentially, it allows the creation of custom graphics that will scale the way that you define, when content added within the image exceeds the normal bounds of the graphic. 
    For a thorough explanation of a NinePatch image, read the discussion in the 2D Graphics document.

    How to make your normal png image to 9patch png.
     Step 1: open Draw9patch.bat file from 


              android->android-sdk-windows->tools->draw9patch.bat

    It will open small java base application which look like this.

    Step 2: Open your PNG file. Or Drag and drop your PNG file into this application Here we will create custom button which has glossy effect.


    Left side is where we will be making image 9 patch. And right side shows equivalent image effect on basis of orientation.

    Step 3: we need to mark the 1px size black color strips or points which we need to be scaled for the image according to orientation of android device.
    So first we will start from top .
    It will control the horizontal stretch of image. 



    As show in figure it will stretch the image from the point which u marked in the image. You can see 1 small black dot on top. That means you have starched the image from that section. You can create multiple section. Just add small black dot on 1 px sixe on top.
    Left section controls vertical section of the image. By which you can divide the your image and scan control vertical stretch of your image.
    Bottom, Right Section controls the image quality. So you can fill almost whole section.
    To delete mark section press shift+Click on them to erase.

    Step 4: Save your file .
    Include your file in as button back ground. Your are done.!


    Author: Deep Mehta

    Twitter Delicious Facebook Digg Stumbleupon Favorites More