I have the following XML:
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/verylongtext" android:layout_weight="1000" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sometext" android:onClick="onClickButton" android:layout_weight="1" />
</LinearLayout>
Though I have set a layout_weight there is still a linebreak in the text on the button, the button should show
sometext
but it shows
somet
ext
Why is this and how can I fix it?
Thanks!
You don’t specify the orientation of your
LinearLayout, so it is defaulting to horizontal. TheTextViewis squeezing theButton. Also, when you useandroid:layout_weight, then you often don’t want to constrain the objects in the layout in the relevant dimension, so you can put “0px” instead of “wrap_content” or “match_parent” and let the weight determine the respective proportional sizes.