Creating fonts on large screens

I searched Stackoverflow and google and I find answers for people who want the fonts to stay the same size, but I want them to get bigger when the screen gets bigger.

In particular, I want very large fonts in my application. On my phone they are 1/2 inch high - perfect. My problem is that they are also 1/2 inch high on my 7 inch tablet, and I want them to grow to be about 1 inch. I tried sp and dp modes, and both just keep fonts of the same physical height, which I don't want. I see that for tablets with 3.2 and higher, there is something new, but I want to support devices from 2.3 and higher. I saw complex code that says it automatically scales the fonts to fit the text in width, but this is not what I need. I want fonts to be equivalent to 100sp on a phone and 200sp on a tablet. I do not have graphics and simple relative layouts with very few elements on the screen.I just need to make some text files bigger for larger screens. I would have thought it would be easy, but I cannot find it.

Here is a typical text 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 direct way to do this?

+5
source share
2 answers
Dimensions

'dp' or 'dip' - especially for identical screens. Thus, there is no particular aspect for you.

In order to implement the different sizes of text you need to create multiple styles and put them in a folder values-xlarge, values-large, values-normaland values-small.

One style will look like this:

<style name="BigTextStyle">
    <item name="android:textSize">50dp</item> <!-- different values in different folders  -->
</style>

And in your text view just specify the style:

<TextView 
    style="@style/BigTextStyle"
    ...
/>
+5
source

I went with the method here: http://developer.android.com/guide/topics/resources/more-resources.html#Dimension and added one line to the dimensions.xls files:

<resources>

<dimen name="padding_small">8dp</dimen>
<dimen name="padding_medium">16dp</dimen>
<dimen name="padding_large">16dp</dimen>
<dimen name="font_size">200sp</dimen>

. views 100sp 200sp.

. , , 5-, Android, , 7- , . , , , , , Google.

:

    <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="@dimen/font_size" />
+3

All Articles