Android 以编程方式调整文本大小,文本超出视图边界,是否修复?
我正在尝试调整线性布局中的行大小,具体取决于布局中的行数(布局具有固定高度)。这些行应始终完全填充父布局。因此,1行是父级的完整大小,2行都是大小的一半,以此类推。 这是可行的,我现在也在尝试调整文本大小,但是当我调整文本大小时,它会被切断,即使文本视图非常大(我打开了jelly bean的show view bounds功能)Android 以编程方式调整文本大小,文本超出视图边界,是否修复?,android,interface,resize,textview,Android,Interface,Resize,Textview,我正在尝试调整线性布局中的行大小,具体取决于布局中的行数(布局具有固定高度)。这些行应始终完全填充父布局。因此,1行是父级的完整大小,2行都是大小的一半,以此类推。 这是可行的,我现在也在尝试调整文本大小,但是当我调整文本大小时,它会被切断,即使文本视图非常大(我打开了jelly bean的show view bounds功能) private void setHeightOfRows(视图组父级){ int height=parent.getHeight(); int childCount=p
private void setHeightOfRows(视图组父级){
int height=parent.getHeight();
int childCount=parent.getChildCount();
for(int i=0;i
此方法在ViewTreeObserver中执行,因此在呈现UI之后
如何在不切断文本的情况下调整文本的大小?SetTextScaleX沿X方向(水平)拉伸文本。它看起来更像是要缩小文本,使其从上到下更小,对吗?在这种情况下,您不需要setTextScaleX,您需要setTextSize。简单的问题。简单解决方案必须存在。:)
- 您是否考虑过使用
和android:padding
android:margin
- minHeaight和minWidth怎么样
- 如果你是按代码做的,那么就有一个
Margin也必须有一个类似的东西setPadding
- 有一个
和setMinHeight
setMinWidth
private void setHeightOfRows(ViewGroup parent) {
int height = parent.getHeight();
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
LinearLayout.LayoutParams p = (LayoutParams) parent.getChildAt(i).getLayoutParams();
p.height = height / childCount;
parent.getChildAt(i).setLayoutParams(p);
((ViewGroup) parent.getChildAt(i)).setClipChildren(false);
Log.i("FontSize", "Set font size to " + 10 / childCount);
((TextView) parent.getChildAt(i).findViewById(R.id.name_text)).setTextScaleX(10 / childCount);// .setTextSize(10/childCount);
}
}