Reputation: 543
I want to remove or hide title bar on top of my app, but only on main Activity, I have 2 more sub activity with navigation bar and blank activity, here is my AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true">
<activity
android:name=".StartingScreen"
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=".AccommodationScreenWithNav"
android:label="@string/title_activity_accommodation_screen_with_nav"
android:parentActivityName=".StartingScreen">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mydomain.test.StartingScreen" />
</activity>
<activity
android:name=".AccommodationDetail"
android:label="@string/title_activity_accommodation_detail"
android:parentActivityName=".AccommodationScreenWithNav">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mydomain.test.AccommodationScreenWithNav" />
</activity>
</application>
So, I want remove or hide only for main activity
not for .AccommodationDetail
I have tried to use Theme.AppCompat.Light.NoActionBar
is work but when I jump to AccommodationDetail activity the app is crash or error.
Please help...
Thanks.
Upvotes: 1
Views: 1467
Reputation: 1747
In your platform/android/res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyTheme" parent="@style/_MyTheme"/>
<style name="_MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
</resources>
In your AndroidManifest.xml
android:theme="@style/Theme.MyTheme"
Upvotes: 1
Reputation: 13368
Before setcontentview add these two lines in your Activity onCreate() method.
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//hide notification bar
Upvotes: 1
Reputation: 19351
For API Level 11+ devices, you can use:
android:theme="@android:style/Theme.Holo.NoActionBar
Another way to solve this kind of problem is to create your own style in style.xml
file and set it to a specific activity like Android Activity in AndroidManifest.xml
file.
Open your style.xml
file, create a new style just like below. Choose your own name and set the parent as below
<style name="your_own_name" parent="Theme.AppCompat.Light.NoActionBar">
</style>
Open your's project AndroidManifest.xml
file, set the theme name for the specific activity you dont want the bar to show and you are done
<activity android:theme ="@style/your_own_name" >
</activity>
Any questions? Please free to ask.
It should help
Upvotes: 2
Reputation: 31304
Set your theme for your main activity to Theme.AppCompat.Light.NoActionBar
, and set your theme for your application to Theme.AppCompat.Light
. If a theme is not explicitly set for an activity, it'll use the theme defined in the application tag.
Upvotes: 3
Reputation: 2825
Please try this -
android:theme="@android:style/Theme.NoTitleBar"
Upvotes: 2