簡體   English   中英

如何停止兩行以上的按鈕上的文本?

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

我在水平線性布局中有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>

還沒有嘗試過,但是嘗試給它一個固定的高度和singleLine="true"

或者試試這個android:maxLines =“ 1”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM