我有以下代码来查找屏幕尺寸计算屏幕上适合多少文本。
现在我需要知道屏幕上有多少行。我有从上升到下降的文本大小。我需要知道行距的高度。getFontSpacing 还给出了从上升到下降的值。
有谁知道是否有办法找到行距的值?
//Code for Getting screen Dimensions
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
//Breaking Text When Width Is Filled
Paint p = new Paint();
p.setTextSize(60);
int textNum = p.breakText(sText, 0, 20, forOrBack, width, null);
//Working Out How Many Lines Can Be Entered In The Screen
float fHeight = p.descent() - p.ascent();
int tHeight = (int) fHeight;
int numLines = height/tHeight;