Java 如何制作自定义文本视图?

Java 如何制作自定义文本视图?,java,android,Java,Android,我的文本视图xml文件 <com.example.blabla.HateTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/hate" android:layout_width="match_parent" android:layout_height="match_parent" android:text="Text" /> 我创造了这样的东西: HateTextV

我的文本视图xml文件

<com.example.blabla.HateTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/hate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Text" />
我创造了这样的东西:

HateTextView h = itemView.findViewById(R.id.hate);
h.setTextHate("some text..");
h.setRotation(number);
只是因为旋转的问题太多了。或者更确切地说是因为反别名。只需从xml getPaint.AntiAlia。。不起作用

在这里,我把“match_parent”放在这里,如果我把我正在绘制的文本的“content”放在这里,它就根本不可见了。如何将“文本”插入到我绘制的文本中

 public void setTextHate(String hate) {
    str = hate;
}

设置str=hate后,必须调用
invalidate()
再次调用onDraw(画布)。

我按你说的做了。这没有帮助,我不知道为什么:(invalidate();在setTextHate方法中?是的。我写了public void setTextHate(String hate){str=hate;invalidate();}。屏幕上的结果是一样的。你能建议我如何用另一种方法来做吗?我只需要在旋转时实现反别名。也许这有帮助,这个视图就是recyclerview中的项
 public void setTextHate(String hate) {
    str = hate;
}