olop01
olop01

Reputation: 273

Disable Action Bar won't work

I am trying to get rid of the Action Bar in my custom app built under API 18, but it still does show when I start it on my Samsung Galaxy S3. I tried the following code:

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">

Also uninstalling and installing the app again did not work. Did I miss something or is it the API level that makes troubles with public class MainActivity extends AppCompatActivity ?? (the reason why I'm asking this is because as I understood AppCompatActivity is a material design thing and my API 18 doesn't support material design yet, so this could be why the code might not be working for me here. (?)

Upvotes: 0

Views: 36

Answers (1)

olop01
olop01

Reputation: 273

Okay I was right with the AppCompatActivity... As soon as I roll back to:

AndroidManifest.xml

android:theme="@style/AppTheme" 

MainActivity.xml

public class MainActivity extends ActionBarActivity {

the Action Bar is gone, as in the code defined above. So it seems that with my old Android Studio (I didn't update it because I'm following a video tutorial in this version and there are too many changes in the newest Android Studio) plus my old API 18 (I only have an older Smartphone) it doesn't delete the action bar correctly. Although Google said they already support older APIs with the new AppCompatActivity, this doesn't seem to work flawless, OR I did something wrong (or forget something) when changing these two lines to make Android Studio shut up about me using deprecated code...

Upvotes: 1

Related Questions