0

カスタムビューのテキストにポップアップ&ゴーバック効果をつけたい。Text Size とPostInvalidate();. ただし、Custom View では効果がありません。

カスタム ビュー OnDraw メソッド:

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    canvas.drawText(carMessage, getPercentOfWidth(40),getPercentOfHeight(20),fontPaint);
    canvas.drawBitmap(carSpriteImage, carspritePosition.x , carspritePosition.y, null);
}

フォント アップデータ スレッド クラス コード:

@Override
public void run() {
    super.run();    

    while(true){

        paint.setTextSize(minSize);
        Log.i("Font Thread!", "Min Font Size="+minSize);
        customeView.setCarMessage("Click Me");
        customeView.setFontPaint(paint);
        customeView.postInvalidate();

        try {
             Thread.sleep(700);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        paint.setTextSize(maxSize);
        customeView.setCarMessage("To Stop");
        customeView.setFontPaint(paint);
        Log.i("Font Thread!", "Max Font Size="+maxSize);
        customeView.postInvalidate();
    }
}
4

1 に答える 1

0

私は自分のプロジェクトhttps://github.com/donvigo/CustomProgressControlsでこれを作成しました。クラスのメソッドchangePercentageを見てください。CircleRoadProgress

于 2013-10-23T07:26:48.643 に答える