2016-03-01 60 views
0

我有了3只的EditText小部件的Android應用。當我輸入值時,一切都很好。當我點擊一個按鈕時,光標和/或文字就像圖像中所示的那樣落在線條下方。我可以點擊並上下拖動文本/光標(就像它是一個日期選擇器或其他東西)。這確實發生在所有3個領域。這發生在設備上和仿真器中。的Android的EditText框和光標/文本走動

我不記得在那些可能導致這一點,例如,檢查所有的屬性沒有揭示什麼會導致它的任何部件光改變任何屬性。即使沒有任何價值,如在折扣場,我可以移動提示文字就像我可以將用戶輸入的值。我想也許它有些事情要做,我在做onClickListener,但我沒有改變任何東西。我可以從溢出菜單中選擇一個選項,它也會在那裏發生。任何想法爲什麼發生這種情況?

該字段的XML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
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" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:showIn="@layout/activity_calc"> 

<TableLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentStart="true" 
    android:id="@+id/tableLayout"> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="match_parent"> 

     <EditText 
      android:layout_width="100dp" 
      android:layout_height="wrap_content" 
      android:inputType="numberDecimal" 
      android:ems="10" 
      android:id="@+id/etxtPrice" 
      android:layout_column="1" 
      android:textAlignment="center" 
      android:hint="Price"/> 

     <EditText 
      android:layout_width="100dp" 
      android:layout_height="wrap_content" 
      android:inputType="numberDecimal" 
      android:ems="10" 
      android:id="@+id/etxtDiscount" 
      android:layout_column="2" 
      android:textAlignment="center" 
      android:hint="Discount" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="%" 
      android:id="@+id/textView" 
      android:layout_column="3" 
      android:textSize="20dp" /> 

     <EditText 
      android:layout_width="100dp" 
      android:layout_height="wrap_content" 
      android:inputType="numberDecimal" 
      android:ems="10" 
      android:id="@+id/etxtTax" 
      android:layout_column="4" 
      android:textAlignment="center" 
      android:hint="Tax" /> 

    </TableRow> 

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

回答

0

由於EditText上的高度爲WRAP_CONTENT ..編輯文本可以容納任何數量的文本行。使用android:singleLine =「true」屬性將其強制爲單行。

+0

添加此行不改變不希望的行爲。 – KiloJKilo