TextView排列(要放在上一个textview最后一行的末尾)
TextView arrangment (to be placed at the end of the last line of previous textview)
有 2 个 Textview
具有不同的背景颜色,第二个 Textview
必须放在第一个 textview's
最后一行的末尾。我需要在哪里以及如何安排第二个 textview
?
Here it shows what i need to achieve
尝试
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:text="Hello"
android:background="@color/colorPrimary"
android:layout_width="wrap_content"
android:layout_height="40dp"/>
<TextView
android:text="world"
android:background="@color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="40dp"/>
</LinearLayout>
通常,我们使用 HTML 文本来获取此信息。
我们可以为不同的文本使用任意多的文本样式。通过这种方式,您可以为每个文本设置不同的属性。
例如:<HTML><text1><text2></HTML>
在上面,你可以独立定义文本属性。最后将此文本放在 Textview 中。所以我们可以使用单个 TextView 本身来实现这一点。
示例:
String str = "<a>This is a <font color='#800000FF'> blue text</font> and this is a <font color='red'> red text</font> </a>";
TextView textView = (TextView)findViewById(R.id.text);
textView.setText(Html.fromHtml(str, Html.FROM_HTML_MODE_COMPACT));
有 2 个 Textview
具有不同的背景颜色,第二个 Textview
必须放在第一个 textview's
最后一行的末尾。我需要在哪里以及如何安排第二个 textview
?
Here it shows what i need to achieve
尝试
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:text="Hello"
android:background="@color/colorPrimary"
android:layout_width="wrap_content"
android:layout_height="40dp"/>
<TextView
android:text="world"
android:background="@color/colorAccent"
android:layout_width="wrap_content"
android:layout_height="40dp"/>
</LinearLayout>
通常,我们使用 HTML 文本来获取此信息。 我们可以为不同的文本使用任意多的文本样式。通过这种方式,您可以为每个文本设置不同的属性。
例如:<HTML><text1><text2></HTML>
在上面,你可以独立定义文本属性。最后将此文本放在 Textview 中。所以我们可以使用单个 TextView 本身来实现这一点。
示例:
String str = "<a>This is a <font color='#800000FF'> blue text</font> and this is a <font color='red'> red text</font> </a>";
TextView textView = (TextView)findViewById(R.id.text);
textView.setText(Html.fromHtml(str, Html.FROM_HTML_MODE_COMPACT));