0

Recently I came across a problem in android, that I developed an application, it's UI very much fit for android device's default font size (Normal).. which is being misaligned when device font size made to Tiny or Huge (Tested in Samsung devices)..How to overcome such problems? What type of UI design techniques need to be followed? If our text being set from Java file atleast we can do some adjustment using

float scale = getResources().getConfiguration().fontScale;

But if the text is being created from xml, How to handle it? Any ideas?

Dovydas Šopa
  • 2,282
  • 8
  • 26
  • 34
RDD
  • 145
  • 1
  • 18
  • "How to handle it?" how to handle what? what is your problem actually? – pskink Jun 16 '15 at 03:56
  • 1
    Do you want to increase/decrease your font size automatically with device font size? – Ajeet Jun 16 '15 at 04:02
  • @pskink Want to handle "UI which will not break if device font size increased" – RDD Jun 16 '15 at 08:05
  • "UI which will not break if device font size increased" and your broken UI looks like...? some images? broad explanation maybe? – pskink Jun 16 '15 at 08:19

2 Answers2

0

If you want to increase/decrease your font size automatically with device font changes then you must need to design your layout accordingly otherwise you can always hardcode your font size any way.

Daud Arfin
  • 2,499
  • 1
  • 18
  • 37
0

Design i don't have idea, but just wana share that when font size increases the text size also increases. We give the text size of the textview in 'sp' which increases along with font size, if you want to avoid this then try to give the text size in 'dp' which will prevent in increment of text size. For example,

    <TextView
    android:id="@+id/label"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="20dp" />

Hope it will help anyone in any case ;)

Android Killer
  • 18,174
  • 13
  • 67
  • 90
  • Can give any official link to confirm this.. Because i followed [this](http://stackoverflow.com/a/2025541/2550183) higly accepted answer, where its mentioned more details about `sp` and `dp` – RDD Jun 16 '15 at 08:09
  • @RDD for above point in my answer I can say i have tried that by myself. And about sp and dp, you can read from internet. But to avoid change of text size as per font, you have to give dp as textSize. – Android Killer Jun 16 '15 at 08:21