2016-09-13 7 views
0

У меня есть TableLayout с двумя столбцами (TextViews слева и EditText в правом столбце). Когда я печатаю слишком много текста редактирования, он выходит из экрана. Как принудительно завернуть на следующую строку, когда ширина EditText будет высокой?Android EditText в TableLayout

<?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> 

ответ

-1

Не пробовал, но попробуйте добавить android:singleLine=true к EditText

+0

Но я хочу иметь более одной строки – miepsik

0

Набор android:inputType="textMultiLine" & android:layout_weight="1" для EditText.

Примечание: textMultiLine не будет работать вместе с numberDecimal.

<EditText 
    android:id="@+id/note_detail" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textMultiLine" 
    android:layout_weight="1" 
    android:textSize="24sp" /> 
Смежные вопросы