简体   繁体   English

TextView dp无法随着屏幕尺寸缩放

[英]TextView dp does not scale with screen size

I am attempting to create a textView that will take up a large portion of the top center part of the screen. 我正在尝试创建一个textView,它将占据屏幕顶部中心部分的很大一部分。 Ideally, setting the text size in dp would allow the textView to remain the correct relative size (taking up about 70% of the width of the screen, and maybe 20% of the top). 理想情况下,在dp中设置文本大小将使textView保持正确的相对大小(占据屏幕宽度的70%,顶部可能占20%)。 It looks correct in the layout editor, and in the emulator at HVGA resolution. 在布局编辑器和HVGA分辨率的仿真器中,它看起来都是正确的。 However, when I test it at higher resolutions (on my tablet, or emulating a 720p display) the text takes up a very small portion of the top center part of the screen. 但是,当我以更高的分辨率(在平板电脑上或模拟720p显示器)对其进行测试时,文本仅占据屏幕顶部中间部分的很小一部分。 (maybe 30% width instead of 70%, and it doesn't seem any larger vertically). (也许是30%的宽度,而不是70%的宽度,并且垂直方向似乎没有更大的宽度)。

Is there a way to scale text to correctly increase relative size with resolution? 有没有办法缩放文本以正确增加分辨率的相对大小?

Set the layout_width as fill_parent , which will make it spread across the screen for all devices. layout_width设置为fill_parent ,这将使其在所有设备的屏幕上散布。 Add some padding on left right and top which seems suitable. 在左右和顶部添加一些似乎合适的填充。 The padding might seem different for different screens but still this might be a better solution. 对于不同的屏幕,填充看起来可能有所不同,但这仍然是更好的解决方案。

设置android:layout_width =“ match_parent”编辑:检查此内容自动缩放TextView文本以适合边界

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM