Reputation: 7936
I have one TextView with only 1 line of text. Now I have to put an extra line to set the state of the user. So I set the property android:lines="2"
the textview looks like:
<TextView
android:id="@+id/providerName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:ellipsize="marquee"
android:fontFamily="sans-serif-light"
android:lines="2"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
The way I add the text is like:
mNameAndStatus.setText(providerNameText + "\n" + mUserStatus);
Image how is actually.
The problem is that the first lines must me in Large text, but the second line must be medium or small and I don't know if is it possible.
How can I achieve this?
Upvotes: 1
Views: 1557
Reputation: 19273
try
String asHtml = firstLine+"<br/><small>"+secondLine+"</small>";
textView.setText(Html.fromHtml(asHtml));
or simply use Spannable (AbsoluteSizeSpan)
Upvotes: 1
Reputation: 2985
You need to do something like this :
mNameAndStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
where your text size is given in sp (24sp in the example).
Here are all TypedValue
s http://developer.android.com/reference/android/util/TypedValue.html
Upvotes: 0