android通过java在textview中对齐文本

nee*_*ang 1 android alignment textview

我有一个textview,其中我通过java追加几行,如下所示.

TextView myTextView = (TextView) findViewById(R.id.mytextview);
myTextView.append("this is line one of the textview");
myTextView.append("this is line two");
myTextView.append("this is line three of the textview");
Run Code Online (Sandbox Code Playgroud)

我想中心只对齐第二行.我尝试过不同的html标签但没有用.有人可以告诉我它是如何在android中完成的.

Mau*_*k J 8

myTextView.setGravity(Gravity.CENTER);
Run Code Online (Sandbox Code Playgroud)