SquareTextView
を使用して、マップマーカーのクラスタアイコンのカスタム字体を設定しようとしています。どのようなクラスのTextViewを拡張するのはandroid-maps-utils-amap
ですか? DefaultClusterRenderer
でこのコードを使用してカスタム書体を設定しますが、効果はありません。だから私はSquareTextViewSquareTextView TypeFaceの設定方法
private SquareTextView makeSquareTextView(Context context) {
SquareTextView squareTextView = new SquareTextView(context);
Typeface typeface = Typeface.createFromAsset(context.getAssets(), "whatever.ttf");
squareTextView.setTypeface(typeface);
}
の書体を変更するには何をする必要があるかを理解するために私を助けそして、これはSquareTextView
のソースコードでください:
package com.amap.api.maps2d.ui;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.TextView;
public class SquareTextView extends TextView {
private int mOffsetTop = 0;
private int mOffsetLeft = 0;
public SquareTextView(Context context) {
super(context);
}
public SquareTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SquareTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = getMeasuredWidth();
int height = getMeasuredHeight();
int dimension = Math.max(width, height);
if (width > height) {
mOffsetTop = width - height;
mOffsetLeft = 0;
} else {
mOffsetTop = 0;
mOffsetLeft = height - width;
}
setMeasuredDimension(dimension, dimension);
}
@Override
public void draw(Canvas canvas) {
canvas.translate(mOffsetLeft/2, mOffsetTop/2);
super.draw(canvas);
}
}
は、あなたが資産ディレクトリではなく、任意のサブディレクトリに 'Roboto-Italic.ttf'ファイルを持っていますか?また、 'Calligraphy'を試してみると、このワイルドカードをスキップすることができます。アプリケーションワイドフォントを設定する場合は – Sourabh