[英]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.