Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓我的自定义主题未应用_Android_Styles_Themes_Manifest - Fatal编程技术网

Android 安卓我的自定义主题未应用

Android 安卓我的自定义主题未应用,android,styles,themes,manifest,Android,Styles,Themes,Manifest,我的res/values/style.xml文件中有以下样式定义: <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <item name="android:tex

我的res/values/style.xml文件中有以下样式定义:

 <!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:textColor">#fff</item>
    <item name="android:textSize">12sp</item>
</style>

<style name="MainActivity" parent="AppTheme">
    <item name="android:textColor">#f0f</item>
    <item name="android:background">@color/black</item> 
</style>

#fff
12便士
#f0f
@颜色/黑色
以及清单文件中的以下代码:

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:theme="@style/MainActivity"
        android:name="com.example.mygateway.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

我希望textColor#f0f将应用于MainActivity,但事实并非如此。 textColor和我尝试过的其他项目均未应用。 实际上,唯一的AppTheme应用于活动和整个应用程序。 我是android开发的初学者。我做错了什么

请帮忙。 谢谢

作为状态:

“如果要从自己定义的样式继承,则不必使用父属性。相反,只需将要继承的样式名称作为新样式名称的前缀,并用句点分隔。例如,要创建继承上面定义的CodeFont样式但颜色为红色的新样式,可以编写如下新样式:


#fff
12便士
#f0f
@颜色/黑色


...
`
<style name="AppTheme" parent="AppBaseTheme">   
    <item name="android:textColor">#fff</item>
    <item name="android:textSize">12sp</item>
</style>

<style name="AppTheme.MainActivity">
    <item name="android:textColor">#f0f</item>
    <item name="android:background">@color/black</item> 
</style>
<activity android:theme="@style/AppTheme.MainActivity" 
    ...>
       ...
</activity>`