External Fonts
You can add your favorite fonts using this code
Syntax:
Typeface typeface_name = Typeface.createFromAsset(getAssets(), "path");
obj_name.setTypeface(typeface_name);
obj_name.setTextSize(text_size);
obj_name.setText("Your Text");
Example:
Typeface font0 = Typeface.createFromAsset(getAssets(), "fonts/GOTHIC.TTF");
TextView txtMessage = (TextView) findViewById(R.id.txtMessage);
txtMessage.setTypeface(font0);
txtMessage.setTextSize(50.f);
txtMessage.setText("hello android");
From where you fetch the Font file?
Understand this screen-shot
Animation List
- Bink
- Bounce
- Cross Fade
- Fade In
- Fade Out
- Move
- Rotate
- Sequential Animation
- Slide Down
- Slide Up
- Zoom In
- Zoom Out
- Together Animation
Download
activity_main.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
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" >
<EditText
android:id="@+id/et1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="10dp"
android:hint="text|textCapCharacters"
android:inputType="text|textCapCharacters" />
<EditText
android:id="@+id/et2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/et1"
android:layout_margin="10dp"
android:hint="text|textEmailAddress"
android:inputType="text|textEmailAddress" />
<EditText
android:id="@+id/et3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/et2"
android:layout_margin="10dp"
android:hint="text|textPassword"
android:inputType="text|textPassword" />
<EditText
android:id="@+id/et4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/et3"
android:layout_margin="10dp"
android:hint="number"
android:inputType="number" />
<EditText
android:id="@+id/et5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/et4"
android:layout_margin="10dp"
android:hint="phone"
android:inputType="phone" />
<EditText
android:id="@+id/et6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/et5"
android:layout_margin="10dp"
android:hint="datetime"
android:inputType="datetime" />
<EditText
android:id="@+id/et7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/et6"
android:layout_margin="10dp"
android:hint="text|textCapSentences|textMultiline"
android:inputType="text|textCapSentences|textMultiLine" />
<EditText
android:id="@+id/et8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/et7"
android:layout_margin="10dp"
android:hint="text|textUri"
android:inputType="text|textUri" />
</RelativeLayout>
</ScrollView>
Screen-Shots
Download
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" >
<Gallery
android:id="@+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<ImageSwitcher
android:id="@+id/imageSwitcher1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/gallery1"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp" >
</ImageSwitcher>
</RelativeLayout>
ImageSwitcherActivity.java
package ums.androideasycode.imageswitcher;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ViewSwitcher.ViewFactory;
public class ImageSwitcherActivity extends Activity implements ViewFactory
{
int imgs[] =
{
R.drawable.love_island,
R.drawable.blue_bird,
R.drawable.paris,
R.drawable.kittens,
R.drawable.morning_paris
};
ImageSwitcher imgSwitcher;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imgSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher1);
imgSwitcher.setFactory(this);
imgSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
imgSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
Gallery gallery = (Gallery) findViewById(R.id.gallery1);
gallery.setAdapter(new ImageAdapter(this));
gallery.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
imgSwitcher.setImageResource(imgs[arg2]);
}
});
}
public class ImageAdapter extends BaseAdapter
{
private Context ctx;
public ImageAdapter(Context c)
{
ctx = c;
}
public int getCount()
{
return imgs.length;
}
public Object getItem(int arg0)
{
return arg0;
}
public long getItemId(int arg0)
{
return arg0;
}
public View getView(int arg0, View arg1, ViewGroup arg2)
{
ImageView iView = new ImageView(ctx);
iView.setImageResource(imgs[arg0]);
iView.setScaleType(ImageView.ScaleType.FIT_XY);
iView.setLayoutParams(new Gallery.LayoutParams(130, 170));
return iView;
}
}
public View makeView()
{
ImageView iView = new ImageView(this);
iView.setScaleType(ImageView.ScaleType.FIT_CENTER);
iView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
iView.setBackgroundColor(0xFF000000);
return iView;
}
}
Screen-Shots
![Kittens Kittens](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_keHodu-dk2PI1NGG4kc6uVsXK8F_eALoX-oCZ6Nys4vPP8jJSjpxyQYoKrNo0GGeCpLl1RACbj6zfmNF-vQtoMn-bOJgpX0yV2oRA-TDIEi71C7A2vy7emVzYtcgQ3taQwGnBaW7TKA/s320/111.png) |
Kittens |
![Blue Bird Blue Bird](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLZH_I_YK2R0-i4JSEcI3sqNQuJYTpjxOP95fFB0leODdpMBJuNDHEbUtnzTqEb2AkcgAiIIGiSna9mOp7MF89r0eaDXOcH42c3xo5uNe3cmAzUoHvMR2S8ZtgtD8JnMNpziAR_zI1I98/s320/222.png) |
Blue Bird |