线性布局中的自动调整文本大小与重量 android java
我想自动调整文本大小。但它是在 LinearLayout 中,我正在使用权重。我尝试过类似的事情:
app:autoSizeTextType="uniform"
android:autoSizeMinTextSize="2sp"
android:autoSizeMaxTextSize="100sp"
android:autoSizeStepGranularity="2sp"
但没有任何效果!有人可以帮助我吗??? (我搜索了很多但没有任何效果)谢谢!
I would like to auto-size my text. But it is in linearLayout and I m using weight. I tried things like that :
app:autoSizeTextType="uniform"
android:autoSizeMinTextSize="2sp"
android:autoSizeMaxTextSize="100sp"
android:autoSizeStepGranularity="2sp"
but nothing worked ! Can someone help me ??? (I searched a lot but nothing worked) Thank you !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
autosize 的工作原理是为视图提供恒定的宽度和宽度。 height ant 然后它会适当地自动调整文本大小。避免在宽度上使用
wrap_content
...如果可能的话,尝试给出精确的宽度/高度,或者您使用wrap_content
具有可变高度,但使用数字或match_parent 固定宽度
autosize works on the principal that you give the view constant width & height ant then it will autosize the text appropriately. Refrain from using
wrap_content
on width... if possible try to give exact width/height or you have have variable height withwrap_content
but fixed width with number ormatch_parent
好吧,我解决了我的问题:
我正在做的是获取relativelayout的大小,而我的textview在里面。然后,我以编程方式调整 TextView 的尺寸,并使用 setAutoTypeUniform 函数使文本适合我的布局。
好吧,伙计们,如果你们有任何问题,请告诉我。我很高兴它对我有用!
Well, I resolved my problem :
What I'm doing is taking the size of a RelativeLayout, and my TextView is inside. Then I dimensioned the TextView programmatically and use setAutoTypeUniform function to fit the text in my layout.
well guys, if you have any problem, tell it to me. I so happy that it works for me !