2012-12-04 73 views
0

我的布局文件作为波纹管为什么android:background对我不起作用?

<?xml version="1.0" encoding="UTF-8" ?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    tools:context=".LimeText" > 


    <TextView 
     android:id="@+id/file_title" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     ***android:background="@color/red"*** 
     android:text="@string/untitled" /> 

    <ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/scroll" 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:fadingEdge="none"> 

      <EditText 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/file_content" 
      ***android:background="@android:color/white"*** 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:padding="5dip" 
       android:fadingEdge="none" 
       android:scrollbars="vertical|horizontal" 
       android:gravity="top" 
       android:autoText="false" 
       android:capitalize="none" /> 

    </ScrollView> 
</LinearLayout> 

但无论我怎么改的背景下,EditText的背景永远留在黑和“TextView的背景始终是灰色的。灰色TextView之前设置了#CCCCCC,但现在我想将其更改为另一个color,它不能。

+0

那是什么,工具:上下文? – gowri

+0

设置颜色代码为背景,如“#454545” – appukrb

+0

请确保您已更改color.xml中的颜色代码 –

回答

0

您的颜色代码文件必须在此路径上。

res/values/colors.xml 

与以下内容

<?xml version="1.0" encoding="utf-8"?> 
    <resources> 
     <color name="edittext_color">#000000</color> 
     <color name="text_color">#00FFFF</color> 
    </resources> 

,现在使用这样的方式。

<EditText 
    android:id="@+id/my_edit" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:maxLength="5" 
    android:background="@color/edittext_color" /> 

希望这会有所帮助。

谢谢。