3

Somebody can please explain this?
Why the third TextView is weird? enter image description here

The definitions for the 2 lines before are the same, and I haven't touched the style with java...

Edit: I've added the XML Layout file. The XML:

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

    <TextView
        android:id="@+id/quadEqu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="25dp"
        android:text="@string/quadequ"
        android:textSize="27sp" />

    <Button
        android:id="@+id/closeBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="30dp"
        android:text="@string/close"
        android:onClick="close" />

    <TextView
        android:id="@+id/stepOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/quadEqu"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="25dp"
        android:text="@string/quadEquForm"
        android:textSize="18sp" />

    <TextView
        android:id="@+id/stepTwo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/stepOne"
        android:layout_below="@+id/stepOne"
        android:text="@string/quadEquForm"
        android:textSize="18sp" />

    <TextView
        android:id="@+id/stepThree"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/stepOne"
        android:layout_below="@+id/stepTwo"
        android:text="@string/quadEquForm"
        android:textSize="18sp" />

</RelativeLayout>
Prem
  • 4,823
  • 4
  • 31
  • 63
Eyal
  • 1,649
  • 3
  • 25
  • 49

3 Answers3

0

It's a strange behaviour.

Try to set the content of the 'stepTwo' to the 'stepThree'. If the same issue appeared, so the problem from the TextView.

You should check if you modify the padding of 'stepThree' textView programmatically.

Mahmoud
  • 2,683
  • 1
  • 30
  • 32
0

In android Text View, when you try to render the subscript, the text gets clipped at the top and bottom. To avoid this, you can try to set the text from HTML.

Example.

stepThree.setText(Html.fromHtml("Some text<sup><small>1</small></sup>"));

stepThree.setText(Html.fromHtml(
        "HCO<sub><small><small>3</small></small></sub>));

Refer this link for more details.

Android TextView's subscript being clipped off

Subscript and Superscript a String in Android

Community
  • 1
  • 1
Prem
  • 4,823
  • 4
  • 31
  • 63
0

You need to change android:layout_height for the TextView (for all 3 is better).

<TextView
    android:id="@+id/stepOne"
    android:layout_width="wrap_content"
    android:layout_height="30dp"
    android:layout_below="@+id/quadEqu"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="25dp"
    android:text="@string/quadEquForm"
    android:textSize="18sp" />

<TextView
    android:id="@+id/stepTwo"
    android:layout_width="wrap_content"
    android:layout_height="30dp"
    android:layout_alignLeft="@+id/stepOne"
    android:layout_below="@+id/stepOne"
    android:text="@string/quadEquForm"
    android:textSize="18sp" />

<TextView
    android:id="@+id/stepThree"
    android:layout_width="wrap_content"
    android:layout_height="30dp"
    android:layout_alignLeft="@+id/stepOne"
    android:layout_below="@+id/stepTwo"
    android:text="@string/quadEquForm"
    android:textSize="18sp" />
Eyal
  • 1,649
  • 3
  • 25
  • 49