3

I wanted that a certain fraction of my screen should have a digit. But while working on that I had a problem that, for certain screens the text was not being displayed and the logcat showed -> Font size too large to fit in cache. While working to solve the problem I tried certain codes and found that whenever the text size was larger than 717 pixels the logcat showed that error.

So, I wanted to know whats the rule for this. Can we not have text size greater than 717 pixels on any device in android ?

Tested on MOTO G phone, Nexus 5 emulator

I tried this to test

Java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent">


   <TextView android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="1"
        android:textSize="717px"/>

</RelativeLayout>

Now when android:textSize was 717 px "1" was displayed on the screen but when I did 718px or above I got the error -> Font size too large to fit in cache. width, height = 170, 511.

What does this error mean ?

Text box height is large enough to have 1 of 717px as following are the dimensions of the devices on which I tested the code and text box is match_parent

Nexus 5 -> screen dimensions 1080*1920 px

Moto g -> screen dimensions 720*1280 px

Abhinav Arora
  • 537
  • 1
  • 7
  • 23
  • Arrived at this question because of the magic number: 717px. I was working on a CSS media query that matches print paper's sizes. And the 717px came up as the width of an A4 paper in Chrome. 483px seemed to be the width of an A5 paper in Chrome, BTW. – leo Dec 16 '16 at 03:42

1 Answers1

3

try like this..

<TextView android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="1"
            android:textSize="717px"/>

and add this too..n try

urtextview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

reference: Font size too large to fit in cache

Community
  • 1
  • 1
M S Gadag
  • 2,057
  • 1
  • 12
  • 15