我已经尝试过this。我计划这样做:
但是它以这种方式显示:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tvHiragana"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hiragana"
android:layout_weight="2"
android:textSize="22sp" />
<TextView
android:id="@+id/tvKanji"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kanji"
android:textColor="@color/redColor"
android:layout_weight="1"
android:textSize="20sp" />
</LinearLayout>
我该怎么做才能使它在
layout_weight
方面正常工作?如何避免在TextView中换行? 最佳答案
我应该怎样做才能使其在layout_weight方面正确运行?
首先,将weight
与horizontal
布局一起使用时,您的width
应该为0dp
。同样,如果布局为vertical
,则height
应该为0dp
。
如何避免在TextView中换行?
如果要使用android:singleLine="true"
将文本限制为单个水平滚动行,而不是将其换行为多行
TextView Docs
如果这不能回答您的问题,请更加清楚,因为这会使您感到困惑。