2015-11-24 111 views
-3

在我的應用程序中,我有一個帶有提示的EditText,在執行時我可以看到提示。但是在輸入時我看不到我鍵入的文本。我將顏色參數設置爲android:textColor="#000000"在編輯文本中,但無法查看我輸入爲黑色的文本。利用主題Android:編輯文本顏色不設置爲黑色

<EditText 
     android:id="@+id/edt_searchContact" 
     android:layout_width="match_parent" 
     android:layout_height="45dp" 
     android:layout_marginLeft="5dp" 
     android:layout_centerVertical="true" 
     android:ems="10" 
     android:textColor="#000000" 
     android:focusable="true" 
     android:clickable="true" 
     android:inputType="text" 
     android:hint="Search..."/> 
    <requestFocus/> 

上午

<style name="Theme.NoTitleBar"> 
    <item name="windowNoTitle">true</item> 
</style> 

任何一個可以幫我的問題。 感謝提前:)

+0

你是什麼意思*好結果* – Mohit

+0

你可以發佈你的'EditText'圖像嗎? –

+0

我的意思是文字顏色不變爲黑色,它仍然是灰色 –

回答

0

方法1:

<EditText 
     android:id="@+id/editText1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:textColor="@color/black"> 

</EditText> 

color.xml(RES /值/ color.xml)

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <color name="black">#000000</color> 
</resources> 

方法2:

在Activity中嘗試一下,java代碼如下:

public class MainActivity extends Activity { 
/** Called when the activity is first created. */ 

EditText et1; 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    et1 = (EditText) findViewById(R.id.editText1);   

    et1.setTextColor(Color.BLACK); 


} 

檢查鏈接: http://www.coderanch.com/t/627146/Android/Mobile/textColor-doesn-change-app

+0

我已經試過這個,但沒有改變。還是文本顏色爲灰色 –

+0

OK,檢查更新的答案,也沒有幫助,然後顯示您正在使用的應用程序的主題,actiivty – Androider

+0

我的主題@ Androider –

1

我遇到了同樣的問題,編輯文本提示是白色的Nexus 7,但在其他設備中,提示是黑色的。

edittext.setHintTextColor(Color.GRAY); 

也設置它以編程方式將解決此問題。

相關問題