[英]why android:background doesn't work for me?
我的布局文件如下
<?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
,但不能。
您的顏色代碼文件必須在此路徑上。
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" />
希望這可以幫助。
謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.