我有5个水平线性布局的按钮,最后一个不能放在屏幕上,所以它被分成两行,例如:
Ita
lian代替Italian
有没有什么办法可以让它不这么做呢?有没有一种动态的方式,在这样一个较小的设备的情况下,它可能只有两个按钮并排放置,它可以将下一个按钮下拉到下一行?可能如下所示:
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>发布于 2011-02-27 11:11:14
或尝试此android:maxLines="1“
发布于 2011-02-26 05:31:26
我还没有试过,但试着给它一个固定的高度和singleLine="true"。
https://stackoverflow.com/questions/5122815
复制相似问题