How to remove title bar in support library? - android

I want to port my app to android support library v7 revision 23.1.
For this purpose I have extended my theme from Theme.AppCompat.NoActionBar as instructed in multitude of guides.
<style name="MyTheme" parent=" Theme.AppCompat.NoActionBar ">
The problem is that the activity shows old android title bar with the name of my application and I cannot remove this title bar. Regarding this the support library is a big step backwards in comparison to holoeverywhere. Not to mention load of other bugs.
I have tried to remove title bar using following adition to my theme:
<style name="MyTheme" parent=" Theme.AppCompat.NoActionBar ">
...
<item name="windowNoTitle">true</item>
<item name="android:windowNoTitle">true</item>
...
</style>
But the title bar persists.
The device runs with android 2.3.5.
How to remove title bar?

You must set
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
also using toolbar
<android.support.v7.widget.Toolbar
android:id="#+id/activity_main_page_toolbar"
android:layout_height="#dimen/actionbar_height"
android:layout_width="match_parent"
android:background="#drawable/actionbar_background"
android:textColorPrimary="#android:color/white"
app:theme="#style/Theme.CustomAppCompat">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_logo"
android:background="#drawable/menu_item_drawable"
android:padding="5dp"
android:clickable="true"
android:id="#+id/toolbar_icon" />
<include layout="#layout/notif_layout" />
</android.support.v7.widget.Toolbar>

Try to create such a style.xml.Its for full screen app.So just delete fullscreen for NoTitleBar.And windowFullScreen to false.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="#style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
</resources>
And such a Mansifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="by.test.roma.usermetrics" >
<application
android:name=".ParseApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.NoActionBar.FullScreen" >
<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>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

Related

ActionBar and title not dissapearing after changes to AndroidManifest.xml and styles.xml in nativescript

Here is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain.project"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="25"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="#style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
And here is my values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- theme to use FOR launch screen-->
<style name="LaunchScreenThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<!--<item name="toolbarStyle">#style/NativeScriptToolbarStyle</item>-->
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
</style>
<!-- theme to use AFTER launch screen is loaded-->
<style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<!--<item name="toolbarStyle">#style/NativeScriptToolbarStyle</item>-->
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme" parent="AppThemeBase">
</style>
<!-- theme for actioon-bar
<style name="NativeScriptToolbarStyleBase" parent="Widget.AppCompat.Toolbar">
<item name="android:background">#color/ns_primary</item>
<item name="theme">#style/ThemeOverlay.AppCompat.ActionBar</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat</item>
</style>
<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
</style> -->
</resources>
I can change values in android:windowFullscreen and the app goes fullscreen or not, accordingly to the boolean set. So, I know that the manifest file is being parsed correctly. However, the title bar / action bar / toolbar is simply never hiding and always appears with the app in the title.
I am using this angular seed, not sure if relevant: https://github.com/TeamMaestro/angular-native-seed
I've been stuck in this for some time now, can someone help? Thanks :)
I can change values in android:windowFullscreen and the app goes
fullscreen or not, accordingly to the boolean set. So, I know that the
manifest file is being parsed correctly. However, the title bar /
action bar / toolbar is simply never hiding and always appears with
the app in the title.
Your manifest is correct, but your preview is set up wrong. You have to remember that the Android Studio preview doesn't reflect how your application will actually look when run on a real device.
I created a dummy project to explain. Here is code that removes the action bar, similar to what you have:
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
Which looks like this in source code:
<style name="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Now this clearly tells the app to not show an action bar, just like your theme does. However, if you look at the preview, you will see this:
So then how do you make your preview accurately reflect your theme? Well, click here:
And adjust your theme to include no action bar!
As a result, you have no action bar in the preview and in the application:
Let me know if this was helpful!
i Go Through Your Code and havent found any Problem ,But Maybe There is issue with code but U can Try Compare with This style that works for me:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<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>
Add this code to style.xml
<style name="AppTheme.NoActionBar.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and add this code to AndroidManifest.xml
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/AppTheme.NoActionBar.NoActionBar">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="#style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"
android:theme="#style/AppTheme.NoActionBar.NoActionBar"/>
Try this in your styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<!-- Customize your theme here. -->

How to set actionBar image with #style

I'm trying to set drawable as image for actionBar in my activity, using #style, but don't see any result...
This is my #styles:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
</style>
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/bgd</item>
</style>
This is my activity code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:theme="#style/MyCustomTheme"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.roughike.bottombar.BottomBar
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_alignParentBottom="true"
app:bb_behavior="shifting|underNavbar"
app:bb_tabXmlResource="#xml/bottombar_tabs_main_screen"/>
Thas's what I have:
That's that actionBar, I want to get:
Im'm trying to use it in exact activity, this is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.workout.mauzerthecat.vesortupdate">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:theme="#style/MyCustomTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Same result;
The solution was like this (as I'm using AppCompat):
My styles:
#style/ActionBar
#style/ActionBar
#drawable/bgd
#drawable/bgd
#mipmap/ic_launcher_round
#mipmap/ic_launcher_round
useLogo|showHome
2.I had to revome any logo atributes from my Manifest file;
3. You can see here Logo are not displayed in Actionbar, using AppCompat

Cannot Change Background Color For Action Bar

I have already tried looking at the following threads to find the answer to my question:
Android unable to change background color of ActionBar
Change Background color of the action bar using AppCompat
...but none of those solutions have helped me fix the problem.
I am attempting to change the background color (among other things) of the actionbar. So far I have been able to change the styles for everything else. Here is my styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
<item name="actionBarStyle">#style/AppTheme.ActionBar</item>
<item name="android:windowBackground">#color/dark_green</item>
<item name="android:buttonStyle">#style/AppTheme.Button</item>
<item name="android:editTextStyle">#style/AppTheme.EditText</item>
<item name="android:listViewStyle">#style/AppTheme.ListView</item>
<item name="android:windowActionBar">true</item>
<!--<item name="android:colorBackground">#color/dark_green</item>-->
</style>
<style name="AppTheme.ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/dark_green</item>
<item name="background">#color/dark_green</item>
<item name="android:colorPrimary">#color/dark_green</item>
<item name="android:colorPrimaryDark">#color/dark_green</item>
</style>
<!-- Button theme -->
<style name="AppTheme.Button">
<item name="android:background">#drawable/background_button</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:padding">20dp</item>
</style>
<!-- Edit Text Theme -->
<style name="AppTheme.EditText">
<item name="android:background">#drawable/background_edittext</item>
<item name="android:padding">14dp</item>
<item name="android:layout_marginBottom">16dp</item>
<item name="android:textColorHint">#color/light_gray</item>
<item name="android:textCursorDrawable">#null</item>
<item name="android:textSize">20dp</item>
</style>
<style name="AppTheme.ListView">
<item name="android:textColor">#color/text_color</item>
<item name="android:divider">#android:color/transparent</item>
</style>
<declare-styleable name="FixedAspectRatioFrameLayout">
<attr name="aspectRatioWidth" format="dimension" />
<attr name="aspectRatioHeight" format="dimension" />
</declare-styleable>
</resources>
Here is my Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.myapp.app">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/myapp_button"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login" />
<activity
android:name=".HomeActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ListOffersActivity"
android:parentActivityName=".HomeActivity"
android:launchMode="singleTop"/>
<activity
android:name=".ViewOfferActivity"
android:label="#string/title_activity_view_offer"
android:parentActivityName=".ListOffersActivity">
</activity>
<activity
android:name=".SettingsActivity"
android:label="#string/title_activity_settings"
android:parentActivityName=".HomeActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="io.myapp.app.HomeActivity" />
</activity>
<activity android:name=".ListSavedOffersActivity"
android:label="Saved Offers"
android:parentActivityName=".HomeActivity"
android:launchMode="singleTop"></activity>
</application>
</manifest>
Well, after a couple days of fiddling with it, I found out that the problem was mainly due to the fact that android (with its new material theme and all...) changes the color in the actionbar when you change the following properties:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:colorPrimary">#color/dark_green</item>
<item name="android:colorPrimaryDark">#color/darker_green</item>
</style>
This properly set the color of the actionbar to #color/dark_green.
You have to sacrifice a slight blink showing the ActionBar style for few milliseconds when the app starts in case you want to use Java for styling any view because it sets up the layout according to layout definition on the style resources.
In case you want to hide from Java it will show a blink of actionbar at beginning.
So will be in other styling case.
So better you style it from style.xml but if the slight blink is ok go with Java.

how to set image to background n text color of action bar?

I want so set backgroung image to actionbar of main activity and all activities too and also want to chnage text color of text of action bar
i tried this code but it giving me error
plz help me
style.xml
<resources>
<!-- Base application theme. -->
<style name="AppThe" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="ActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/actionbar_background</item>
</style>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBar</item>
</style>
</resources>`
manifest code
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hp.navigationd"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="OLXA"
android:theme="#style/AppThe" >
<activity
android:name="com.example.hp.navigationd.MainActivity"
android:label="OLXA" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.hp.navigationd.post_ad"
android:label="#string/Ad_Details"
android:parentActivityName="com.example.hp.navigationd.MainActivity" />
<activity android:name="com.example.hp.navigationd.My_account" />
<activity android:name="com.example.hp.navigationd.My_fav" />
<activity android:name="com.example.hp.navigationd.My_ads" />
<activity android:name="com.example.hp.navigationd.My_chats" />
<activity android:name="com.example.hp.navigationd.Rules" />
<activity android:name="com.example.hp.navigationd.Help" />
<activity android:name="com.example.hp.navigationd.About_us" />
</application>
</manifest>
Try this,
Insted of using,
<style name="AppThe" parent="Theme.AppCompat.Light.DarkActionBar">
use this,
<style name="AppThe" parent="#android:style/Theme.Holo.Light.DarkActionBar">
Check out the below style.
<style name="AppThe" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="actionBarStyle">#style/ActionBar</item>
</style>
<style name="ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
<item name="background">#drawable/actionbar_background</item>
</style>
Here you need to use both you both android:actionBarStyle and actionBarStyle as well as android:background and background items. The former is for newer versions of android that support ActionBar natively. The latter is for older android versions.
About the error:
You can not use "#android:style/Theme.Holo.Light" with AppCompatActivity

Why does my Action Bar not overlay?

I am new to Android development. I have followed the Android Overlay training at:
http://developer.android.com/training/basics/actionbar/overlaying.html
and spent the last few days trying to get this to work. I am using the AppCompat library and my min SDK is 7 and my max sdk is 18.
My application defines a custom style and looks like this:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomActionBarTheme" >
<activity
android:name="com.example.rtrt.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>
My layout looks like this:
<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" >
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/clickme"
android:onClick="sendMessage" />
</RelativeLayout>
My theme.xml looks like this:
<style name="CustomActionBarTheme"
parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style> <!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">#android:color/transparent</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>
</style>
The application compiles and runs... however, the Button appears below (not under) the ActionBar. When I hide the ActionBar the Button moves to the top of the screen. When the ActionBar is made visible, the Button is repositioned down the screen.
Why is my ActionBar not floating (overlaying)?
Would appreciate any help here.
It is because you are targeting below SDK 11.
change your theme to AppCompat and not AppCompat.Light:
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#android:style/Theme.AppCompat">
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>
</style>

Categories

Resources