الكود المستخدم
//الكود الاول
}
public class Typewriter extends TextView {
private CharSequence mText;
private int mIndex;
private long mDelay = 2000;
public Typewriter(Context context) {
super(context);
}
public Typewriter(Context context, AttributeSet attrs) {
super(context, attrs);
}
private Handler mHandler = new Handler();
private Runnable characterAdder = new Runnable() {
@Override
public void run() {
setText(mText.subSequence(0, mIndex++));
if(mIndex <= mText.length()) {
mHandler.postDelayed(characterAdder, mDelay);
}
}
};
public void animateText(CharSequence text) {
mText = text;
mIndex = 0;
setText("");
mHandler.removeCallbacks(characterAdder);
mHandler.postDelayed(characterAdder, mDelay);
}
public void setCharacterDelay(long millis) {
mDelay = millis;
}
}
{
//الكود الثاني
Typewriter hevo = new Typewriter(MainActivity.this);
hevo.setCharacterDelay(200);
hevo.animateText("HEVO TEAM");
hevo.setGravity(Gravity.CENTER);
hevo.setTextSize(20);
hevo.setTextColor(Color.parseColor("#FF3344"));
hevo.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/hevoteam.ttf"), 0);
linear1.addView(hevo);
التصنيف :
سكيتشوير