Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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在TableLayout中的应用_Android_Xml - Fatal编程技术网

Android EditText在TableLayout中的应用

Android EditText在TableLayout中的应用,android,xml,Android,Xml,我有两列的TableLayout(左边是TextView,右边是EditText)。当我在编辑文本中键入过多内容时,它会从屏幕上消失。当EditText的宽度太大时,如何强制换行到下一行 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.andro

我有两列的TableLayout(左边是TextView,右边是EditText)。当我在编辑文本中键入过多内容时,它会从屏幕上消失。当EditText的宽度太大时,如何强制换行到下一行

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.miebs.debt.PaymentDetail">

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/payment_detail_table"
    android:stretchColumns="1">

    <TableRow>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/column_1_right_margin"
            android:text="@string/Debtor"
            android:textSize="24sp" />

        <TextView
            android:id="@+id/debtor_detail"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="24sp" />
    </TableRow>

    <TableRow>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/column_1_right_margin"
            android:text="@string/Amount"
            android:textSize="24sp" />

        <EditText
            android:id="@+id/Amount_detail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/column_1_right_margin"
            android:inputType="numberDecimal"
            android:textSize="24sp" />
    </TableRow>

    <TableRow>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/column_1_right_margin"
            android:text="@string/Date"
            android:textSize="24sp" />

        <TextView
            android:id="@+id/date_detail"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="showDialog"
            android:text="" />

    </TableRow>

    <TableRow>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/column_1_right_margin"
            android:text="@string/Note"
            android:textSize="24sp" />

        <EditText
            android:id="@+id/note_detail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/column_1_right_margin"
            android:textSize="24sp" />
    </TableRow>

</TableLayout>


还没有尝试过,但是尝试将
android:singleLine=true
添加到EditText

设置
android:inputType=“textMultiLine”
&
android:layou weight=“1”
用于
EditText

注意:
textMultiLine
不能与
numberDecimal
一起使用


当用户输入时(超过20-30个字符),TableLayout android:stretchColumns=“1”中的这一行将把编辑文本延伸到屏幕之外

这个问题可以通过使用

<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/payment_detail_table"
android:stretchColumns="0"
android:shrinkColumns="1">


对于edittext中的多行使用,
edittext.setLines(int)在活动文件中,其中“int”是行数。

但我希望有多行
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/payment_detail_table"
android:stretchColumns="0"
android:shrinkColumns="1">