1

我正在尝试复制现有的 Android 项目以开始半新项目。在我的旧项目中,我能够将自定义主题应用于应用程序。在我的新应用程序中,即使我复制了所有 style.xml 文件并更改了清单中的最小和目标 sdk 版本,我也无法为其构建最小/目标 sdk。它可以构建,但我的应用程序顶部仍然有旧式通知栏,而不是操作栏。我不知道如何强制 IntelliJ/Android 为新版本构建。

我的清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.app"
          android:versionCode="1"
          android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CALL_PHONE"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-sdk android:minSdkVersion="11"
              android:targetSdkVersion="16"/>
    <application
            android:label="@string/app_name"
            android:theme="@style/AppTheme"
            android:icon="@drawable/app_icon"
            android:name=".injected.C2Application"
            >
        <activity android:name=".HomeActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

我的风格

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <item name="android:actionBarStyle">@style/LoginActionBarStyle</item>
        <item name="android:textColorHint">#D1D1D1</item>
    </style>

    <style name="LoginActionBarStyle" parent="@android:style/Widget.Holo.ActionBar">
        <item name="android:displayOptions">showHome</item>
        <item name="android:background">#333333</item>
    </style>

    <style name="LoginFormContainer">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:padding">16dp</item>
    </style>
</resources>

现在的样子

现在的样子

它应该喜欢什么

在此处输入图像描述

我不知道什么是/没有被设置。

4

1 回答 1

3

您需要从 Holo 继承的 V11+ 的第二个样式文件。查看正确方法的最简单方法是创建一个新的 hello world 项目,然后看看他们是如何做到的。

还值得一提的是,使用这种技术,操作栏只会在 V11+ 设备上显示。要在所有设备上显示它,您需要使用ActionBarSherlock,但由于您的最低版本设置为 11,因此您可能不打算支持 2.3 手机。

例子:

样式.xml

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

值-v11 样式.xml

<resources>

<!--
    Base application theme for API 11+. This theme completely replaces
    AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
    <!-- API 11 theme customizations can go here. -->
</style>

值-v14 样式.xml

<resources>

<!--
    Base application theme for API 14+. This theme completely replaces
    AppBaseTheme from BOTH res/values/styles.xml and
    res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <!-- API 14 theme customizations can go here. -->
</style>

清单.xml

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.test.test.com.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>

于 2013-06-05T14:31:14.703 回答