0

我在水平线性布局中有 5 个按钮,最后一个按钮无法显示在屏幕上,因此分为两行,例如:

Ita
lian

代替Italian

无论如何我可以强迫它不这样做吗?有没有一种动态的方式,在这种较小的设备的情况下,它可能只能并排放置 2 个按钮,它可以将下一个按钮放到下一行?也许类似于以下内容:

English German 
Italian Spanish
French

这是我的 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/speakFrench"
                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>
4

2 回答 2

2

没有尝试过,但尝试给它一个固定的高度和singleLine="true".

于 2011-02-25T21:31:25.680 回答
2

或者试试这个 android:maxLines="1"

于 2011-02-27T03:11:13.997 回答