I have distributed spaces to the views by allotting them weights in Linear Layout. The height of the textView as can be seen is (Height of the screen*5)/12.
The xml file of the layout is as following-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.greenloop.numbers.Counting_Ten"
android:orientation="vertical"
tools:ignore="MergeRootFrame"
android:background="#FFA500">
<RelativeLayout android:id="@+id/rel_number_fragment"
android:layout_weight="5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#800000">
<TextView
android:id="@+id/number"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:clickable="true"
android:onClick="onClick"
android:background="#800080"/>
</RelativeLayout>
<FrameLayout
android:id="@+id/image_frame"
android:layout_weight="6"
android:layout_width="match_parent"
android:layout_height="0dp">
</FrameLayout>
<fragment android:name="com.example.Navigation_Buttons"
android:id="@+id/button_fragment"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
</LinearLayout>
I have set the textsize in the java file as
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int screen_height = displaymetrics.heightPixels;
text_size = (int) (((screen_height*5.0)/12.0));
textview.setTextSize(TypedValue.COMPLEX_UNIT_PX,text_size);
Now the problem -: I have run this on my phone and everything was fine. Text size was as big as the text view. But when I run the same thing on GENYMOTION emulator of a 10" tablet and a Nexus 5 the Logcat showed - Font size too large to fit in cache. width, height = 175, 527. I am not able to figure this out. Can it be due to difference in font style ?