我的TextView
中的字符串增长并溢出,有时隐藏另一个TextView
的文本或开始消失时,我遇到了问题。
我希望它像这样工作(我知道这看起来很像秋千FlowLayout
,但是由于对齐方式不固定,一个组件左对齐,另一个组件右对齐,所以看起来不太一样):
-------------------------------------
|[TextView0] [TextView1]|
-------------------------------------
当文本增长时:
TextView0 grows: TextView1 grows:
------------------------------------- -------------------------------------
|[TextView0 TextView0 TextView0] | |[TextView0] |
| [TextView1]| | [TextView1 TextView1 TextView1]|
------------------------------------- -------------------------------------
是否可以使用现有布局(可能使用布局的组合)来完成?
如果确实需要构建新的布局,我想举个可行的例子。
我已经尝试过
ReleativeLayout
和LinearLayout
,但是从未使它起作用:RelativeLayout
:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/TextView0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="TextView0" />
<TextView
android:id="@+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="TextView1" />
</RelativeLayout>
当文本开始重叠时,我尝试将
TextView0
修复为toLeftOf="TextView1"
。但是在这种情况下,TextView0
消失了。LinearLayout
:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/TextView0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView0" />
<TextView
android:id="@+id/TextView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="TextView1" />
</LinearLayout>
在这里,
TextView
开始干扰,并且当TextView0
达到全宽时,TextView1
消失了(其宽度趋于零)。 最佳答案
该Android-FlowLayout的最佳库之一
它简单,易于使用且很棒。