我必須使用材質設計將應用程序移植到棒棒糖。當我運行移植的應用程序,我有以下錯誤:app移植到appcompat v22.2.1引發異常IllegalArgumentException:AppCompat不支持當前主題功能
Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:363)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
要口,我創建了Android Studio中的一個項目,該項目實現工具欄和導航抽屜的應用程序。該代碼使用Activities的層次結構,我讓上層基類繼承AppCompatActivity並實施NavigationView.OnNavigationItemSelectedListener。 OnNavigationItemSelectedListener對層次結構中的中間類返回true,最後的子活動實現它。 Gradle沒有提出任何錯誤。
對於主要活動,佈局僅包含ListView和菜單項。我使用了Android Studio生成的默認佈局,並在content_main.xml文件中設置了我的ListView。由於ListView控件不支持CoordinatorLayout,當我實例化ListView中我加(引here)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mListMain.setNestedScrollingEnabled(true);
}
我發現這個topic這似乎談論相同的異常。但是,我的樣式文件遵循主題中提出的建議。
styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
styles.xml(V21):使用任一AppTheme或AppTheme.NoActionBar
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
在清單中不作任何差異
唯一的例外是在在MainActivity的的setContentView線提高,我的佈局,除了content_main文件
activity_main.xml中由Android Studio中創建的:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
app_bar_main。 xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="aklal.org.materialclient.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
content_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="aklal.org.materialclient.MainActivity"
tools:showIn="@layout/app_bar_main">
<ListView
android:id="@+id/listMainAct"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</RelativeLayout>
上什麼錯誤任何想法?任何幫助將高度讚賞
編輯:我不明白的是,即使我評論的一切(在佈局和代碼)相關的ListView,異常仍引發
編輯:看來,問題來自於代碼,我會給解決方案時,我發現它
不幸的是它是不可能對我來說,因爲應用程序是使用Apache的HttpClient lib中,有一些的[這些類與api23刪除](http://stackoverflow.com/questions/32180500使用23.1.1/Android的API-23-刪除程序包)。有一些[解決方案](http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio),但我不能重新編碼所有類與另一個http客戶端,所以我必須嘗試找到一個解決方案,讓應用程序與api22運行。 –