2

I am searching for a long time but I was not successful.

Is there any method, so that the TextView size increases depending on the device screen size?

So far I am using the below code but even then I am facing this sort of issue. I want to set larger size than textAppearanceLarge in below code.

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium" />  

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge" /> 

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall" />   

If I set some fixed size, say android:textSize="32sp" it may look large for Screen sizes like Galaxy Ace but looks small in S3-like devices.

Any related answers are welcomed and thank you in advance.

Kaiser
  • 606
  • 8
  • 22
VIGNESH
  • 2,023
  • 8
  • 31
  • 46
  • 2
    http://stackoverflow.com/questions/9877946/text-size-and-different-android-screen-sizes is that the wanted behaviour? – julthedroid May 02 '13 at 13:45

2 Answers2

1

I think you have to create different value folder so that android will recognize the screen resolution is change. Following link provide you a solution

Different text size for different hardware

Community
  • 1
  • 1
UnderGround
  • 450
  • 1
  • 3
  • 17
0

Use /res/values/dimens.xml with different dimension like:

<resources>

<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">30dp</dimen>
<dimen name="activity_vertical_margin">30dp</dimen>

<!-- For Login Screens -->
<dimen name="button_text_size">16sp</dimen>
<dimen name="edittext_text">14sp</dimen>
<dimen name="checkbox_text">13sp</dimen>

<!-- for Slide bar -->
<dimen name="slide_text_size">13sp</dimen>
<dimen name="slide_button_text_size">15sp</dimen>

<!-- for City Activity -->
<dimen name="list_item_text_size">16sp</dimen>

Now for /res/values-sw600dp/dimens.xml

<resources>

    <!--
         Customize dimensions originally defined in res/values/dimens.xml (such as
         screen margins) for sw600dp devices (e.g. 7" tablets) here.
    -->
    <!-- For Login Screens -->
    <dimen name="button_text_size">16sp</dimen>
    <dimen name="edittext_text">14sp</dimen>
    <dimen name="checkbox_text">14sp</dimen>
    <!-- for Slide bar -->
    <dimen name="slide_text_size">14sp</dimen>
    <dimen name="slide_button_text_size">16sp</dimen> 
<resources>
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437