Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-Edittext中WrapText的问题_Android_Android Edittext - Fatal编程技术网

Android-Edittext中WrapText的问题

Android-Edittext中WrapText的问题,android,android-edittext,Android,Android Edittext,我在EditText中设置WrapText类工具时遇到了麻烦 问题:当我尝试在EditText中输入数据时,它超出了屏幕宽度(水平滚动)。而不是,它应该出现在下一行中 想要执行:实际上,我想要实现多行edittext,最初它应该像往常一样以单行显示,但当输入数据时,它将垂直(而不是水平)展开 请建议我该怎么办?? 请看下图: 我已经完成了以下XML编码: <TableLayout android:layout_width="fill_parent" android:

我在EditText中设置WrapText类工具时遇到了麻烦

问题:当我尝试在EditText中输入数据时,它超出了屏幕宽度(水平滚动)。而不是,它应该出现在下一行中

想要执行:实际上,我想要实现多行edittext,最初它应该像往常一样以单行显示,但当输入数据时,它将垂直(而不是水平)展开

请建议我该怎么办??

请看下图:

我已经完成了以下XML编码:

<TableLayout 
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"
    android:paddingTop="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:stretchColumns="1">

    <TableRow android:id="@+id/TableRow02" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <TextView 
            android:text="Name:" 
            android:id="@+id/TextView01" 
            android:layout_width="80dp" 
            android:layout_height="wrap_content"
            android:textSize="16dip">
        </TextView>
        <EditText 
            android:id="@+id/txtViewName" 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content"
            android:inputType="textFilter|textMultiLine|textNoSuggestions"
            android:scrollHorizontally="false">
        </EditText>
    </TableRow>
</TableLayout>


您可以尝试将
宽度更改为
填充父项。
如果要将编辑文本换行,请尝试在编辑文本中添加以下代码:


android:singleLine=“true”


或者将edittext的宽度设置为fill\u parent或dip中的任何值(如果需要多行)。

我已经在2.1模拟器上对其进行了测试,该模拟器将代码(在编辑文本中包含fill\u parent)封装在该相对布局中,并且似乎没有问题

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingTop="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:stretchColumns="1">

    <TableRow android:id="@+id/TableRow02" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <TextView
            android:text="Name:"
            android:id="@+id/TextView01"
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:textSize="16dip">
        </TextView>
        <EditText
            android:id="@+id/txtViewName"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:inputType="textFilter"
            android:scrollHorizontally="false">
        </EditText>
    </TableRow>
</TableLayout>
</RelativeLayout>


也许您可以在eclipse大纲窗口中导航xml树,并查看哪个视图比屏幕大

我只是改变了这一点:
android:layout\u width=“0dip”
它工作正常


多行编辑文本但最初显示一行,当输入越来越多的数据时,它将垂直(而不是水平)展开。

只需同时使用
android:stretchColumns=“1”
android:shrinkColumns=“1”
而不是唯一的
android:stretchColumns=“1”



不工作,我尝试过,但没有成功,当输入更多文本时,edittext会水平滚动。请检查上面的更新:想执行:@pm paresh mayani为什么不在RelativeLayout中使用,我想它会工作得很好。嘿,在我的问题中检查这个安卓:inputType=“textFilter | textMultiLine”,那么,如何设置android:singleLine=“true”,这有什么意义吗???我从这篇文章中得到了提示/启示:-1@Pedro Fraca:首先仔细阅读问题,然后发布答案。用户到底想要什么。我根据问题更改了答案。我认为这个解决方案可以满足问题作者的需求。
<TableLayout 
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"
    android:paddingTop="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:stretchColumns="1"
    android:shrinkColumns="1">