1
我知道我的問題的標題聽起來像一個已經被回答的問題。 但是,我的問題是不同的,我找不到解決方案如何更改背景圖像的edittext集中狀態
在我的應用程序中,我有一個登錄屏幕與兩個EditText。我使用Theme.Holo.Light的修改版本。
的EditTexts是這樣的:
正如你可以看到有不同顏色的文字下方的邊框,這取決於EditText上的狀態。
所以這裏是我的問題:任何人都可以告訴我如何改變這些邊界的顏色?
我希望任何人都可以幫助我!提前致謝!
編輯:
不幸的是,我遇到了一個另一個問題:
我能夠改變使用dtmilano解決方案的背景圖像。 但是,添加一個StateListDrawable刪除了EditView的填充。如果我添加文本,則光標位於最左邊的位置,而不是像之前那樣位於所描述的邊框內。到目前爲止,我無法引入這種填充,例如用android:paddingLeft。
誰能告訴我哪個屬性得到了覆蓋,通過使用這個選擇
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:state_pressed="true"
android:drawable="@drawable/edittext_pressed"
/> <!-- pressed -->
<item
android:state_focused="true"
android:drawable="@drawable/edittext_focused"
/> <!-- focused -->
<item
android:drawable="@drawable/edittext_default"
/> <!-- default -->
</selector>
和一個EditText這樣的:
<EditText
android:id="@+id/loginEmail"
android:background="@drawable/edittext_modified_states"
android:inputType="textEmailAddress"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
非常感謝,這沒有把戲! – didhavn 2012-07-13 00:03:54
不幸的是,我遇到了其他問題並編輯了我的問題。你能幫我嗎,dtmilano? – didhavn 2012-07-13 00:32:55
使用[9個補丁](http://developer.android.com/reference/android/graphics/NinePatch.html),以便您可以指定內容的去向 – 2012-07-13 03:09:44