Showing posts with label edittext. Show all posts
Showing posts with label edittext. Show all posts

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 

Friday, 8 June 2012

EditText in android

EditText in android



  • EditText in android is works as Text field.
  • You can get the data from the user.
  • Android gives facility to enter different type of data as per the requirement.
  • Two ways to create EditText in android
    • Using xml file in layout

               <EditText
              android:id="@+id/hello"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:hint="this is hint" />
       
    • Using java code in activity class
             
               EditText tvDynamic = new EditText (this);
              tvDynamic.setText("---> Dynamically created EditText ");
  • Types of EditText in android
    • Simple EditText
       
    • Password EditText
      • android:inputType="textPassword"
         
    • Number EditText
      •  android:inputType="number"
    • Password EditText
      •  android:inputType="textPassword"
    • Email EditText
      •  android:inputType="textEmailAddress"

    • MultiLine EditText
      •  android:inputType="textMultiLine"
         
    • Number EditText
      •  android:inputType="phone"
         
    • Time EditText
      •  android:inputType="time"
         
    • Date EditText
      •  android:inputType="date"
         
    • Number Signed EditText
      •  android:inputType="numberSigned"

Related links :

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Review