1

I don't know if that's possibole or not, but i'm trying to achieve some thing like this :

enter image description here

Second line is bold, what i already done :

enter image description here

<TextView
        android:id="@+id/checkIn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/text"
        android:layout_below="@+id/text"
        android:layout_marginLeft="5dp"
        android:padding="2dp"
        android:text="Check-in Date \n 10-08-2017"
        android:drawableLeft="@drawable/ic_calendar"
        android:textColor="@color/hintColor"
        android:drawablePadding="2dp"
        android:transitionName="price"
        android:textSize="@dimen/textInfoSmall" />

3 Answers3

2

Simple way is to Use two TextViews

Or try SpannableString as explained here

How to make part of the text Bold in android at runtime?

Nishin Raj
  • 121
  • 5
1

You should either use two textviews or you can use

Textview tvcheckIn = (TextView) findViewById(R.id.checkIn);
tvcheckIn.setText( Html.fromHtml("First Line<br><b>Second Line"));
Arun Shankar
  • 2,603
  • 2
  • 26
  • 36
1

I think the better practice is separate it into two TextView wrapped inside an Layout.

Because the texts "Check-in Date" and "Check-out Date" is always static. So use separate TextView will reduce String concatenate (Eg: textView.setText("Check-in Date \n" + checkInDate);), and make the source easier to read and extend.

If you still want to highlight part of text in TextView, there is already an answered question here: Android - Highlight a Word In a TextView?. This is all about SpannableString.

nhoxbypass
  • 9,695
  • 11
  • 48
  • 71