为什么这是我的主题导致我的应用崩溃?

时间:2019-09-02 00:29:37

标签: java android themes

我正在开发一个开源Android项目。以前,它的目标是SDK版本22,并使用支持库“ com.android.support:appcompat-v7:22.1.1”。一切都很好。然后将其迁移到AndroidX,并定位到目标SDK版本28,现在甚至无法在模拟器上启动。

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.moire.opensudoku"
android:installLocation="auto">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme">
    <activity
        android:name=".gui.FolderListActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".gui.SudokuListActivity"
        android:label="@string/app_name">
    </activity>
    <activity
        android:name=".gui.SudokuEditActivity"
        android:label="@string/edit_sudoku">
        <intent-filter>
            <action android:name="android.intent.action.INSERT" />
            <action android:name="android.intent.action.EDIT" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".gui.FileImportActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Dialog">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="*"
                android:pathPattern=".*\\.sdm"
                android:scheme="file" />
            <data
                android:host="*"
                android:pathPattern=".*\\.sdm"
                android:scheme="http" />
            <data
                android:host="*"
                android:pathPattern=".*\\.opensudoku"
                android:scheme="file" />
            <data
                android:host="*"
                android:pathPattern=".*\\.opensudoku"
                android:scheme="http" />
        </intent-filter>
    </activity>
    <!-- This activity is here to keep backward compatibility, use SudokuImportActivity instead. -->
    <activity android:name=".gui.ImportSudokuActivity">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>
    <activity
        android:name=".gui.SudokuImportActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Dialog">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:mimeType="application/x-opensudoku" />
        </intent-filter>
    </activity>
    <activity
        android:name=".gui.SudokuExportActivity"
        android:label="@string/app_name">
    </activity>
    <activity
        android:name=".gui.SudokuPlayActivity"
        android:label="@string/app_name">
    </activity>
    <activity
        android:name=".gui.GameSettingsActivity"
        android:label="@string/game_settings">
    </activity>
    <activity
        android:name=".gui.FileListActivity"
        android:label="@string/app_name">
    </activity>
</application>

styles.xml

<style name="Theme" parent="Base.ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="Theme.Default">
    <item name="lineColor">@color/default_lineColor</item>
    <item name="sectorLineColor">@color/default_sectorLineColor</item>
    <item name="textColor">@color/default_textColor</item>
    <item name="textColorReadOnly">@color/default_textColorReadOnly</item>
    <item name="textColorNote">@color/default_textColorNote</item>
    <item name="backgroundColor">@color/default_backgroundColor</item>
    <item name="backgroundColorSecondary">@color/default_backgroundColorSecondary</item>
    <item name="backgroundColorReadOnly">@color/default_backgroundColorReadOnly</item>
    <item name="backgroundColorTouched">@color/default_backgroundColorTouched</item>
    <item name="backgroundColorSelected">@color/default_backgroundColorSelected</item>
    <item name="backgroundColorHighlighted">@color/default_backgroundColorHighlighted</item>
</style>

<style name="Theme.Paper">
    <item name="lineColor">@color/default_lineColor</item>
    <item name="sectorLineColor">@color/default_sectorLineColor</item>
    <item name="textColor">@color/default_textColor</item>
    <item name="textColorReadOnly">@color/default_textColorReadOnly</item>
    <item name="textColorNote">@color/default_textColorNote</item>
    <item name="backgroundColor">@color/default_backgroundColor</item>
    <item name="backgroundColorSecondary">@color/default_backgroundColor</item>
    <item name="backgroundColorReadOnly">@color/default_backgroundColor</item>
    <item name="backgroundColorTouched">@color/default_backgroundColorTouched</item>
    <item name="backgroundColorSelected">@color/default_backgroundColorSelected</item>
    <item name="backgroundColorHighlighted">@color/default_backgroundColorHighlighted</item>
</style>

<style name="Theme.GraphPaper">
    <item name="lineColor">@color/default_lineColor</item>
    <item name="sectorLineColor">@color/default_sectorLineColor</item>
    <item name="textColor">@color/default_textColor</item>
    <item name="textColorReadOnly">@color/default_textColorReadOnly</item>
    <item name="textColorNote">@color/default_textColorNote</item>
    <item name="backgroundColor">@color/default_backgroundColorReadOnly</item>
    <item name="backgroundColorSecondary">@color/default_backgroundColor</item>
    <item name="backgroundColorTouched">@color/default_backgroundColorTouched</item>
    <item name="backgroundColorSelected">@color/default_backgroundColorSelected</item>
    <item name="backgroundColorHighlighted">@color/default_backgroundColorHighlighted</item>
</style>

<style name="Theme.Light">
    <item name="lineColor">@color/light_lineColor</item>
    <item name="sectorLineColor">@color/light_sectorLineColor</item>
    <item name="textColor">@color/light_textColor</item>
    <item name="textColorReadOnly">@color/light_textColorReadOnly</item>
    <item name="textColorNote">@color/light_textColorNote</item>
    <item name="backgroundColor">@color/light_backgroundColor</item>
    <item name="backgroundColorSecondary">@color/light_backgroundColorSecondary</item>
    <item name="backgroundColorReadOnly">@color/light_backgroundColorReadOnly</item>
    <item name="backgroundColorTouched">@color/light_backgroundColorTouched</item>
    <item name="backgroundColorSelected">@color/light_backgroundColorSelected</item>
    <item name="backgroundColorHighlighted">@color/light_backgroundColorHighlighted</item>
</style>

<style name="Theme.PaperLight">
    <item name="lineColor">@color/light_lineColor</item>
    <item name="sectorLineColor">@color/light_sectorLineColor</item>
    <item name="textColor">@color/light_textColor</item>
    <item name="textColorReadOnly">@color/light_textColorReadOnly</item>
    <item name="textColorNote">@color/light_textColorNote</item>
    <item name="backgroundColor">@color/light_backgroundColor</item>
    <item name="backgroundColorSecondary">@color/light_backgroundColor</item>
    <item name="backgroundColorReadOnly">@color/light_backgroundColor</item>
    <item name="backgroundColorTouched">@color/light_backgroundColorTouched</item>
    <item name="backgroundColorSelected">@color/light_backgroundColorSelected</item>
    <item name="backgroundColorHighlighted">@color/light_backgroundColorHighlighted</item>
</style>

<style name="Theme.GraphPaperLight">
    <item name="lineColor">@color/light_lineColor</item>
    <item name="sectorLineColor">@color/light_sectorLineColor</item>
    <item name="textColor">@color/light_textColor</item>
    <item name="textColorReadOnly">@color/light_textColorReadOnly</item>
    <item name="textColorNote">@color/light_textColorNote</item>
    <item name="backgroundColor">@color/light_backgroundColorReadOnly</item>
    <item name="backgroundColorSecondary">@color/light_backgroundColor</item>
    <item name="backgroundColorTouched">@color/light_backgroundColorTouched</item>
    <item name="backgroundColorSelected">@color/light_backgroundColorSelected</item>
    <item name="backgroundColorHighlighted">@color/light_backgroundColorHighlighted</item>
</style>

<style name="Theme.HighContrast">
    <item name="lineColor">@color/highcontrast_bright</item>
    <item name="sectorLineColor">@color/highcontrast_bright</item>
    <item name="textColor">@color/highcontrast_bright</item>
    <item name="textColorReadOnly">@color/highcontrast_bright</item>
    <item name="textColorNote">@color/highcontrast_bright</item>
    <item name="backgroundColor">@color/highcontrast_dark</item>
    <item name="backgroundColorSecondary">@color/highcontrast_dark</item>
    <item name="backgroundColorReadOnly">@color/highcontrast_grey</item>
    <item name="backgroundColorTouched">@color/highcontrast_select</item>
    <item name="backgroundColorSelected">@color/highcontrast_select</item>
    <item name="backgroundColorHighlighted">@color/highcontrast_highlight</item>
</style>

<style name="Theme.InvertedHighContrast">
    <item name="lineColor">@color/highcontrast_dark</item>
    <item name="sectorLineColor">@color/highcontrast_dark</item>
    <item name="textColor">@color/highcontrast_dark</item>
    <item name="textColorReadOnly">@color/highcontrast_dark</item>
    <item name="textColorNote">@color/highcontrast_dark</item>
    <item name="backgroundColor">@color/highcontrast_bright</item>
    <item name="backgroundColorSecondary">@color/highcontrast_bright</item>
    <item name="backgroundColorReadOnly">@color/highcontrast_invertedGrey</item>
    <item name="backgroundColorTouched">@color/highcontrast_invertedSelect</item>
    <item name="backgroundColorSelected">@color/highcontrast_invertedSelect</item>
    <item name="backgroundColorHighlighted">@color/highcontrast_invertedHighlight</item>
</style>

</resources>

当我将android:theme="@style/Theme"更改为android:theme="@style/Theme.AppCompat"时,它可以正常启动,但ListActivity类中没有ActionBar。以前有。我不知道为什么会这样。

0 个答案:

没有答案