0

I need help with combining two text view to complete my spelling bee interface. As shown below my underscore and the text it separated with a huge gap. What can i do to merge them? enter image description here

As requested below contains my xml codes for the text view. I put them both in a linear layout to try to center them both together. The only problem seems to be only the gap.

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="28dp"
    android:gravity="center_horizontal"
    android:layout_below="@+id/btnSound"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true">

    <TextView android:text="@string/randomwords" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/RandomWords"
        android:textSize="25sp"
        android:layout_below="@+id/btnSound"
        android:layout_centerHorizontal="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="25sp"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:id="@+id/lblUnderscore"
        android:gravity="top" />
</LinearLayout>

Answer FOUND!! Using FRAMELAYOUT.

enter image description here

It's close but not perfect.

enter image description here

hamham
  • 21
  • 6

2 Answers2

0

Just switching to a relative layout and adding a layout_below should fix things:

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="28dp"
    android:gravity="center_horizontal"
    android:layout_below="@+id/btnSound"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true">

    <TextView android:text="@string/randomwords"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/RandomWords"
        android:textSize="25sp"
        android:layout_below="@+id/btnSound"
        android:layout_centerHorizontal="true" />

    <TextView android:layout_below="@id/RandomWord"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="25sp"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:id="@+id/lblUnderscore"
        android:gravity="top" />
</RelativeLayout>

You could also put the underlines first (so it ends up behind) and on the randomwords use layout_bottom to get the letters to overline the underscores slightly if thats what you want

Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
0

How about do like this with one textview?

Textview tv= (TextView)findViewById(R.id.randomwords);
tv.setText(Html.fromHtml(test("prospective")));

.............

public String test(String str) {
    char [] charArr = str.toCharArray();
    String htmlStr = "";
    for (int i = 0; i < charArr.length; i++) {
        htmlStr += "<u>" + charArr[i] + "</u>"+" ";
    }
    return htmlStr;
}
Charles
  • 139
  • 6