2012-02-07 31 views
0

我有一個EditText和d我改變他的背景在某一時刻有:的Android的EditText bacground

EditText textEmail; 
textEmail.setBackgroundColor(Color.RED); 

的問題是,該大綱的EditText以及在前看不見我在屏幕上有一個大紅色的東西。 我如何改變這一點,也許設置一個更大的輪廓...

謝謝你。

這裏是我的XML佈局:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/bg_white" > 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:background="@null" 
    android:src="@drawable/bg_mdpi" /> 

<EditText 
    android:id="@+id/editText2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:hint="Password" 
    android:inputType="textPassword" 
    android:password="true" 
    android:maxWidth="220px"/> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_below="@+id/editText2" 
    android:layout_marginTop="35dp" 
    android:minWidth="220px" 
    android:onClick="goLoging" 
    android:text="Login" /> 

<Button 
    android:id="@+id/button2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBaseline="@+id/button1" 
    android:layout_alignBottom="@+id/button1" 
    android:layout_alignParentRight="true" 
    android:minWidth="220px" 
    android:text="Forgot Password" /> 

<ProgressBar 
    android:id="@+id/progressBar1" 
    style="?android:attr/progressBarStyleLarge" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/imageView1" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="52dp" 
    android:visibility="gone" /> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@+id/imageView1" 
    android:layout_centerHorizontal="true" 
    android:hint="Email Adress" 
    android:inputType="textEmailAddress" /> 

</RelativeLayout> 
+0

可以請您發佈XML佈局 – user936414 2012-02-07 10:24:22

+0

完成@ user936414 – 2012-02-07 10:26:09

+0

http://stackoverflow.com/a/5073055/265167 – 2012-02-07 10:26:14

回答

1

剛剛修復的EditText高度和檢查。這可能是因爲wrap_content。

+0

謝謝雅克布的回答對我的部分幫助,現在,Edittext不會觸及董事會,但我放棄了我的EditText的輪廓,一切都是紅色的,輪廓已經消失。 – 2012-02-07 10:36:45

+0

由於setBackgroundColor方法屬於View類,綱要將消失。如果你想要的大綱也使用自定義圖像或繪製EditText – user936414 2012-02-07 10:56:19

+0

好的謝謝。我會做的 – 2012-02-07 11:04:08