要设置Android的lineSpacingExtra,可以在xml布局文件中使用android:lineSpacingExtra属性,或者在代码中使用setLineSpacing(float add, float mult)方法。
在xml布局文件中使用android:lineSpacingExtra属性:
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" android:lineSpacingExtra="8dp" /> 在代码中使用setLineSpacing(float add, float mult)方法:
TextView textView = findViewById(R.id.textView); textView.setText("Hello World!"); textView.setLineSpacing(8, 1.0f); 在上面的例子中,lineSpacingExtra的值为8dp,可以根据需要调整。