问题描述
我已搜查#1和谷歌我觉得是谁想要字体大小仍保持不变的人的答案,但我希望他们能得到更大的时候,屏幕变大。
I have searched Stackoverflow and google and what I find is answers for people who want fonts to remain the same size but I want them to get bigger when the screen gets bigger.
具体来说,我想在我的应用程序非常大的字体。在我的电话,他们是1/2英寸高 - 完美。我的问题是在我的7寸平板他们也是1/2英寸高,我希望他们能够扩大和大约1英寸高。我曾尝试SP和DP模式,都只是不停的字体相同的物理高度,这不是我想要的。我看到有一些新的东西与3.2和更高版本平板电脑,但我想从2.3及更高版本支持的设备。我所看到的复杂code,它说,它自动缩放字体,以适合在宽文但这并不是我所需要的。我想要的字体是说100SP对平板电脑和手机上200SP等效。我没有图形和简单的相对布局在屏幕上非常少的元素。我只需要一对夫妇的textsizes的大屏幕更大。我想这将是简单,但我不能找到它。
Specifically, I want very large fonts in my application. On my phone, they are 1/2 inch high - perfect. My problem is that on my 7 inch tablet they are also 1/2 inch high and I want them to scale up and be about 1 inch high. I have tried sp and dp modes and both just keep the fonts the same physical height, which is not what I want. I see there is something new for tablets with 3.2 and higher but I want to support devices from 2.3 and higher. I have seen complex code that says it auto scales fonts to fit the text in a width but that is not what I need. I want the fonts to be the equivalent of say 100sp on a phone and 200sp on the tablet. I have no graphics and simple relative layouts with very few elements on the screen. I just need to make a couple of the textsizes larger for large screens. I would think it would be simple but I can't find it.
下面是一个典型的文本视图条目
Here is a typical text view entry
<TextView
android:id="@+id/textDistance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/labelDistance"
android:layout_centerHorizontal="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff"
android:textSize="100sp" />
有一个相对简单直接的方式做到这一点?
Is there a relatively simple straight forward way to do this?
推荐答案
DP或探底的尺寸 - 为特制一直在不同的屏幕相同。因此,有没有适合你的任务的任何特殊尺寸。
'dp' or 'dip' dimensions - specially made for been the same on different screens. So, there is not any special dimension for you task.
有关实施不同的文本大小,你必须创建几种风格,并把它们放在文件夹价值观XLARGE
,价值观大
,值正常
和值小
。
For implementing different text sizes you have to create several styles, and put them in folders values-xlarge
, values-large
, values-normal
and values-small
.
一个风格将是这样的:
<style name="BigTextStyle">
<item name="android:textSize">50dp</item> <!-- different values in different folders -->
</style>
而在你的文本视图只是提供样式的引用:
And in your text view just provide style reference:
<TextView
style="@style/BigTextStyle"
...
/>
这篇关于让字体变得更大了大屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!