I used getSupportActionBar().hide(); The result is as expected, action bar hidden during app testing but in XML design view its still visible and thats a problem because i need to visualise how the app looks. Any way i can make it disappear in the XML design view?
Asked
Active
Viewed 684 times
2 Answers
1
That's happening because you are programmatically disabling actionbar, and your IDE doesn't know if it happens or not.
Add this to res/values/style.xml
(create one if you don't have one)
<style name="AppThemeNoTitleBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
and put this under application
tag in AndroidManifest.xml
android:theme="@style/AppThemeNoTitleBar"
so from the scratch (assuming you don't have anything, it should look like this.
res/values/style.xml
<resources>
<style name="AppThemeNoTitleBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp" >
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppThemeNoTitleBar" >
<activity
android:name=".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>
</manifest>

Saehun Sean Oh
- 2,103
- 1
- 21
- 41
-
ok thats clears it up a bit. though im a little confused as to what is ActionBar and what is Title? what does this do- "this.requestWindowFeature(Window.FEATURE_NO_TITLE);" ? – Shreyans Oct 10 '15 at 00:21
-
1http://stackoverflow.com/questions/19279222/android-whats-the-difference-between-a-title-bar-and-an-aciton-bar – Saehun Sean Oh Oct 10 '15 at 00:22
-
also if i do as said above i dont need to do it programmarically too right? ie i dont need to edit .java file? and will it happen to all my activities? is yes then how can i chose which activity whould have or not have action bar? – Shreyans Oct 10 '15 at 00:22
-
1These days ActionBar is mostly used instead of titlebar – Saehun Sean Oh Oct 10 '15 at 00:23
-
1This XML property is globally applied because the theme is applied to the application scope. So you don't need to do that in Activity classes (.java files) – Saehun Sean Oh Oct 10 '15 at 00:24
-
What is your activity's name? put it there – Saehun Sean Oh Oct 10 '15 at 00:29
-
sorry about that. error removed. i had copy pasted entire manifest file you gave but i just need to edit android:theme. But can you tell me how to apply different theme to different activities? – Shreyans Oct 10 '15 at 00:31
-
instead of putting the theme property in the application scope, you can put that in activity scope and apply to different activities. Take a look at here. http://stackoverflow.com/questions/19125163/apply-a-theme-to-an-activity-in-android – Saehun Sean Oh Oct 10 '15 at 00:35
0
I think you have theme for your activity in your manifest. if you remove your theme that contains the actionbar, problem is solved.

BabakHSL
- 622
- 1
- 8
- 18