我是靠谱客的博主 害羞耳机,这篇文章主要介绍android字体变斜,Android 自定义倾斜字体,现在分享给大家,希望可以做个参考。

public class RotateTextView extends AppCompatTextView {

private static final int DEFAULT_DEGREES = 0;

private int mDegrees;

public RotateTextView(Context context) {

super(context, null);

}

public RotateTextView(Context context, AttributeSet attrs) {

super(context, attrs, android.R.attr.textViewStyle);

this.setGravity(Gravity.CENTER);

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RotateTextView);

mDegrees = a.getDimensionPixelSize(R.styleable.RotateTextView_degree, DEFAULT_DEGREES);

a.recycle();

}

@Override

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

super.onMeasure(widthMeasureSpec, heightMeasureSpec);

setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());

}

@Override

protected void onDraw(Canvas canvas) {

canvas.save();

canvas.translate(-27,25);

canvas.rotate(mDegrees);

super.onDraw(canvas);

canvas.restore();

}

public void setDegrees(int degrees) {

mDegrees = degrees;

}

}

android:id="@+id/info"

android:layout_width="72dp"

android:layout_height="72dp"

android:gravity="center"

android:text="哈 哈"

android:textColor="@color/colorWhite"

android:textSize="@dimen/font14"

app:degree="-46dp" />

最后

以上就是害羞耳机最近收集整理的关于android字体变斜,Android 自定义倾斜字体的全部内容,更多相关android字体变斜,Android内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部