我正在尝试制作两个位于同一行的 TextView。第一个应该左对齐,第二个右对齐,当其中一个比第一个大时(左对齐应该在新行上)。当第二个 TextView(右对齐的)变得太大时,我能够使第一个 TextView 换行,但问题是它没有显示其中的全部信息。所以任何人都有任何想法。我希望它与RelativeLayout 一起使用,但任何帮助将不胜感激。
最佳答案
您应该使用 android:layout_weight
来实现这一点,这应该是这样的:
<LinearLayout .....
android:orientation="horizontal" >
<TextView android:id="@+id/txtView1"
android:layout_height="wrap_content"
android:gravity="left"
android:text="TextView Left"
android:layout_width="0dp"
android:layout_weight="1" />
<TextView android:id="@+id/txtView2"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_width="0dp"
android:text="TextView Right"
android:layout_weight="1" />
</LinearLayout>
关于java - Android 中两个 TextView 发生冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18762997/