I have a 2 textviews in a line, TV1 has a short text and TV2 will be text wrapped, here is the displayed text:
TV1 TV2TV2TV2TV2TV2TV2
TV2TV2TV2TV2
What I wanted to do is to have something like:
TV1 TV2TV2TV2TV2TV2TV2
TV2TV2TV2TV2
Please let me know if that's even possible with 2 Textviews
Code:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/TV1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:textAlignment="textStart"
android:textIsSelectable="false"/>
<TextView
android:id="@+id/TV2"
style="@style/text_view_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="?attr/selectableItemBackground"
android:includeFontPadding="false"/>
</LinearLayout>
Better make it as single textview appending two text with tab spaced. To show different designing between two text, use spannablestring. SpannabelString can also be used as clickable text. For ex.
SpannableString text = new SpannableString("Welcome to Skholingua.com, Click here to visit webpage or here to call me or here get Toast.");
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View view) {
Toast.makeText(context,"yup, this is a ClickableSpan and you have clicked it.",Toast.LENGTH_LONG).show();
}
};
text.setSpan(clickableSpan, 77, 91, 0);