水纹上升的动画

来源:互联网 发布:月课程表软件 编辑:程序博客网 时间:2024/05/11 04:15
public class TitanicMainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_imitate_titanic_main);        TitanicTextView tv = (TitanicTextView) findViewById(R.id.my_text_view);        // set fancy typeface        tv.setTypeface(Typefaces.get(this, "Satisfy-Regular.ttf"));        // start animation        new Titanic().start(tv);    }

}

import android.content.Context;import android.graphics.Typeface;import android.util.Log;import java.util.Hashtable;public class Typefaces {    private static final String TAG = "Typefaces";    private static final Hashtable<String, Typeface> cache = new Hashtable<String, Typeface>();    public static Typeface get(Context c, String assetPath) {        synchronized (cache) {            if (!cache.containsKey(assetPath)) {                try {                    Typeface t = Typeface.createFromAsset(c.getAssets(), assetPath);                    cache.put(assetPath, t);                } catch (Exception e) {                    Log.e(TAG, "Could not get typeface '" + assetPath + "' because " + e.getMessage());                    return null;                }            }            return cache.get(assetPath);        }    }}






0 0
原创粉丝点击