我最近开始开发一个Android应用程序。虽然我不是编程新手,自2009年以来我一直在使用Java编程,但这是我第一个Android应用程序。我已经尝试了一些关于如何设置背景颜色的教程,但是它对我来说根本没有起作用。我无法弄清楚我做错了什么。
在我的布局目录中,我有名为main.xml和view_fact.xml的文件。它们都使用线性布局,我的LinearLayout标记如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background_grey"
>
在我的“values”目录中, “strings.xml”的内容如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Facts</string>
<color name="background_grey">#E8E8E8</color>
</resources>
但是背景颜色没有从默认黑色改变。
我还尝试在AndroidManifest.xml文件中添加:"android:theme="@android:style/Theme.Light""。
这些都不起作用,有什么建议吗?
谢谢。
在我的view_fact.xml页面上,它看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background_grey"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fact:"
android:padding="10dp"
android:textColor="#080808"
/>
<TextView
android:id="@+id/factData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text=""
/>
<Button
android:id="@+id/anotherFactButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Another Fact"/>
</LinearLayout>
有趣的是,“factData”中的文本是灰色的,而上面的TextView中的“Fact:”文本是白色的,我尝试将其颜色更改为红色,但它不起作用。它仍然是白色的。
有什么建议吗?我仍然没有成功地解决这个问题;谢谢。