首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我如何停止我的按钮上的文本超过2行?

我如何停止我的按钮上的文本超过2行?
EN

Stack Overflow用户
提问于 2011-02-26 05:22:55
回答 2查看 462关注 0票数 0

我有5个水平线性布局的按钮,最后一个不能放在屏幕上,所以它被分成两行,例如:

代码语言:javascript
运行
复制
Ita
lian

代替Italian

有没有什么办法可以让它不这么做呢?有没有一种动态的方式,在这样一个较小的设备的情况下,它可能只有两个按钮并排放置,它可以将下一个按钮下拉到下一行?可能如下所示:

代码语言:javascript
运行
复制
English German 
Italian Spanish
French

这是我的main.xml

代码语言:javascript
运行
复制
<?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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-02-27 11:11:14

或尝试此android:maxLines="1“

票数 2
EN

Stack Overflow用户

发布于 2011-02-26 05:31:26

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5122815

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档