我想以编程方式获取文本视图的高度或至少行数,但日志显示为 0。出了什么问题?这是我的代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_off);
titreOff = (TextView) findViewById(R.id.offTitre);
titreOff.setText("some text"); // displays 2 lines of text with the font size I used
System.out.println(titreOff.getLineCount() + " and " + titreOff.getHeight());
}
感谢您的建议