简体   繁体   中英

Top of Android superscript being clipped

I tried and searched for a solution to this problem to no avail. The top of letters, such as the tail in a lower-case "d" are being clipped off. Here's is what I currently have:

Codewise:

From the onClickHandler.....

String selectedorder = ""; ... if (num_players == 3) { editor.putString("prefPrefp3_name", child.getText().toString()); selectedorder = "3 rd ";} ... order.setText(Html.fromHtml(selectedorder));

From the CursorAdapter BindView.................

        TextView tv4 = (TextView) view.findViewById(R.id.dspplyrorder); 
        tv4.setText(Html.fromHtml(playersCursor.getString(PlayerOrder)));

And from the XML, where I'm trying to get @+id/dspplyrorder to NOT CLIP the tail of the "d" in my superscript...................

<LinearLayout android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView android:id="@+id/dsp_id"
            android:layout_width="120dip"
            android:layout_height="wrap_content"/>
        <TextView android:id="@+id/dspplyrname"
            android:layout_width="180dip"
            android:textColor="#7CFC00"
            android:textStyle="italic"
            android:layout_marginRight="20dip"
            android:layout_marginLeft="20dip"
            android:paddingRight="3dp"
            android:gravity="left"      
            android:textSize="25sp"
            android:layout_height="wrap_content"/>
        <TextView android:id="@+id/dspplyrorder"
            android:layout_width="30dip"
            android:gravity="left"
            android:textColor="#FFFFFF"      
            android:textSize="16sp"
            android:layout_height="wrap_content"/>
        <ToggleButton android:id="@+id/button_toggle"
            android:text="@string/buttons_1_toggle"
            android:textOff="Select"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:onClick="myClickHandler" />
  </LinearLayout>

I am not worried about affecting the line spacing of lines above or below, which seems to be the most often occurring problem discussion. I must be doing something really dump, since no one else seems to have this problem. HELP Please.

This solution worked for me.

Superscripted text is usually made smaller when the browser renders it, that doesn't seem to happen here so you can replicate that (and solve this problem) by doing this:

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

Set the following for your TextView:

android:setIncludeFontPadding="true"

That should do it. Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM