Reputation: 311
I have layouts like this, but I cannot put it into a shape
That is the look I want from my layouts, the break text needs to be below of about
About: A car is good to go
So you need things to make it going
But this is the look I get, this is my layout code,
About: A car is good to go
So you need things to make it going
This is my layout code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/ColorPrimary"
android:textSize="18sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/five"
android:textSize="18sp"/>
</LinearLayout>
How can I change my layout so break text could be below my layout. Thank you
Upvotes: 1
Views: 116
Reputation: 25194
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/five"
android:textSize="18sp"/>
We need to put the whole text into this single TextView. We retrieve it and apply a span:
TextView t = findViewByid(R.id.text);
Spannable s = new SpannableString("About: car is good to go so you need things to make it going");
s.setSpan(new ForegroundColorSpan(Color.BLUE), 0, 7, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
t.setText(s);
Upvotes: 2
Reputation: 2100
Remove marginLeft attribute from TextView and set orientation to Vertical in the LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/ColorPrimary"
android:textSize="18sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/five"
android:textSize="18sp"/>
Upvotes: 1