开发者

How can I stop the text on my buttons spanning over 2 lines?

I've got 5 buttons in a horizontal linear layout, the last one can't fit on the screen so its broken into two lines such as :

Ita
lian

Instead of Italian

Is there anyway I can force it to not do this? Is there a dynamic way, in such a case of a smaller device where it may only fit 2 buttons side by side that it could drop the next down to the next row? Maybe something like the following :

English German 
Italian Spanish
French

This is my main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >
    <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/prompt"
            />
    <EditText
            android:id="@+id/inputText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:orientation="horizontal"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
            >
        <Button
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/speakEnglish"
                android:onClick="speakEnglish"/>
        <Button
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/speakSpanish"
                android:onClick="speakSpanish"/>
        <Button
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/spe开发者_C百科akFrench"
                android:onClick="speakFrench"/>
        <Button
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/speakGerman"
                android:onClick="speakGerman"/>
        <Button
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/speakItalian"
                android:onClick="speakItalian"/>
    </LinearLayout>
</LinearLayout>


Or try this android:maxLines="1"


Haven't tried it but try giving it a fixed height and singleLine="true".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜