I have a LinearLayout as below.
<LinearLayout
android:id="@+id/messageLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="horizontal" />
Into this layout, dynamic TextViews are added at runtime. But before inserting at runtime I tried adding 5 texviews manually. This is how it looks like.
The layout for those textview is
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
I need the last text to gracefully follow normally rather than just breaking down as in the above image.
Where am I wrong? Could you help me figure this out?
EDIT
I have a message to display. For instance, England beats Australia in the final championship. Those bold texts have some ids attached which when clicked opens a dialog. So I break the text and add them as different TextViews so I could easly attach an onClickListener. I need the message to look one single text. Hope it makes more sense now.
EDIT 2
I used clickableSpan as a get around.
SpannableString spannableString = new SpannableString(message);
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View widget) {
Log.i(TAG_NAME, "clickable span...");
}
};
spannableString.setSpan(clickableSpan, 0, 13, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
spannableString.setSpan(clickableSpan, 30, 40, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
All I am trying to do is add multiple span to a textview. However, it looks like only last span is working. Where am I going wrong?