有没有直接测量文字高度的方法?我现在这样做的方法是使用Paint measureText()来获取宽度,然后通过试验和错误找到一个值来获得近似高度.我也一直在搞乱FontMetrics,但所有这些似乎都是近似的方法.
我正在尝试扩展不同分辨率的东西.我可以做到,但我最终得到了令人难以置信的冗长代码,并通过大量计算来确定相对大小.我讨厌它!一定有更好的方法.
我想计算行(或布局)高度(在DP中),它只包含使用默认行间距时的TextView结果TextView text size?
这个布局的IE:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/minRow1col1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textIsSelectable="false"
android:textSize="11dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
布局/线高是多少?(任何公式?我不需要运行时的值)
谢谢 !