我試圖擺脫在API 18中構建的自定義應用程序中的操作欄,但它在我的Samsung Galaxy S3上啓動時仍顯示。我嘗試下面的代碼:禁用操作欄將無法正常工作
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
activity_main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".MainActivity"
android:background="#FFC107" android:theme="@style/AppTheme">
而且卸載和安裝應用程序再次沒有工作。我錯過了什麼,或者它是API級別,使得與公共類MainActivity擴展AppCompatActivity ?? (我之所以問這是因爲,據我瞭解,AppCompatActivity是一個材料設計的東西,我的API 18不支持材質設計,所以這可能是爲什麼這裏的代碼可能不適合我。
您的活動使用這種風格?佈局是否包含工具欄? –
我更改了AndroidManifest&MainActivity中的代碼(請參閱下文),以使Android Studio使用不推薦的代碼關閉我,但似乎只更改兩行並不能完全升級現有項目(這就是爲什麼操作欄仍然存在顯示),所以我回滾到原來的代碼(見下文) – olop01