I have tried this. I planned to do like this:
But it showing in this way:
<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>
What should I do make it work correct in the terms of layout_weight
? How to avoid making new lines in TextView?
What should I do make it work correct in the terms of layout_weight?
First, when using weight
with a horizontal
layout, your width
should be 0dp
. Similarly, if your layout is vertical
then your height
should be 0dp
.
How to avoid making new lines in TextView?
use android:singleLine="true"
if you want to
Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines
If this doesn't answer your question then please be a little more clear because its a bit confusing on what you're asking.