2011-11-21 96 views
5

我建了一個屏幕,看起來像這樣:的EditText失去了它的邊界失敗後提交

但如果登錄失敗畫面原來是這個樣子:

我使用了EditText,代碼如下所示:

<TextView android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:text="email"></TextView> 
     <EditText 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:id="@+id/username" 
      android:hint="" 
      android:textStyle="normal" 
    android:singleLine="true" 
      android:inputType="textEmailAddress">     
     </EditText> 
     <TextView android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:text="password"> 
     </TextView> 
     <EditText 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:id="@+id/uc_txt_password" 
      android:hint="" 
      android:textStyle="normal" 
    android:singleLine="true" 
      android:inputType="textPassword"> 
     </EditText> 

任何想法?

更新: 似乎虛假顯示器是默認情況下顯示在冰淇淋三明治上的方式。我使用的是舊版本的android(2.2),顯示器看起來像第一張附加的圖片。

+1

@Vivek請您編輯多加小心,你已經刪除了圖像。 –

+0

哦,我很抱歉,我沒有注意到這一點。非常感謝@ Shadow Wizard –

+0

這些是默認的edittext背景嗎? – jakk

回答

2

ICS引入一個更「開放」的文本佈局(查看gmail應用程序),其中編輯文本的默認樣式缺少邊框。如果你不希望它看起來像設備的設置,你應該更嚴格地定義你的風格,以便在所有設備上使用它。也許使用一些9個補丁映像和狀態選擇器xml文件。因此,如果您將背景設置爲白色而不定義任何其他樣式,則可能會繼承Holo.Dark並將其用作編輯文本bg:https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png

因此,沒有可見的文本。更嚴格地定義你的風格,或者更好地設置你的主題,而不要重寫其他背景。

+0

我知道我需要爲ICS找到更好的解決方案(在更新中說) - 感謝鏈接。 – alfasin

+0

不知道爲什麼你付出了賞金......如果你只是獲得了良好的背景9補丁和定義你的風格你的問題已解決所有當前的API級別。如果你願意的話,你甚至可以從GB分支的資源中竊取9個補丁。 – Sleepybear

+0

@Sleepybar什麼是GB分支? GitHub?你是對的,但我不知道如何刪除賞金,也許我應該只是獎勵給你... :)但嚴重的是,我寧願找到bug並修復它然後去解決方法。 – alfasin

0

嘗試使用Android選擇

<?xml version="1.0" encoding="utf-8"?> 

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:drawable="@drawable/editbox_dropdown_background" android:state_focused="false"/> 
    <item android:drawable="@drawable/editbox_background_focus_yellow" android:state_focused="true"/> 
    /> 
</selector>