[英]Dynamically change Textview size
Is it possible to change the single textView size dynamically? 是否可以动态更改单个textView的大小? In the below link the text size is dynamically changed. 在下面的链接中,文本大小是动态更改的。 ? ? can anyone guide me on how to do this. 谁能指导我如何做到这一点。 thanks in advance 提前致谢
Thanks for all, at-last i used three different textview to design whatever i need. 谢谢大家,最后我使用了三种不同的textview来设计所需的东西。 Thanks for all. 谢谢大家
Try following code 尝试以下代码
span.setSpan(new RelativeSizeSpan(0.8f), start, end,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Here, you need to set start
and end
as per your requirement. 在这里,您需要根据需要设置start
和end
。 0.8f
is size of text here. 0.8f
是此处的文本大小。 You need to pass float
value here. 您需要在此处传递float
值。
Code 码
textView = (TextView) findViewById(R.id.textView);
Spannable span = new SpannableString(textView.getText());
span.setSpan(new RelativeSizeSpan(0.8f), 0, 7,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
span.setSpan(new RelativeSizeSpan(1.8f), 7,
txt.getText().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
txt.setText(span);
Output 产量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.