Can't hide titlebar Titanium with Alloy - android

I have encounterd a problem in Titanium Appcelerator using Alloy MVC. This problem contains the following(see image)
I can't remove the black bar where the app name and logo is found. I am running the app on a device(Google Nexus, no simulator)
I have tried the following to remove this:
XML:
<Alloy>
<Window>
</Window>
</Alloy>
TSS:
"Window":
{
navBarHidden:true,
fullscreen:true,
backgroundColor:"Orange",
orientationModes:[Ti.UI.PORTRAIT],
}
TiApp.XML:
<statusbar-style>default</statusbar-style>
<statusbar-hidden>true</statusbar-hidden>
<fullscreen>true</fullscreen>
<navbar-hidden>true</navbar-hidden>
But none of these options are working to hide this black bar. In the iOS simulator it does remove the navigation bar by only setting the property fullscreen to true
Are there other options to get this away? Thanks in advance!

If you're using Titanium SDK 3.3.0, the Titanium theme, which is one of the default themes, now hides the action and status bar. To use it, just add this to your tiapp.xml.
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="#style/Theme.Titanium"/>
</manifest>
</android>
You can read more about this and other themes that Titanium has for Android here: Android Themes.

Is it the ActionBar that's showing perhaps? Try hiding it.
To modify the theme to hide the action bar:
Add a custom theme file to your project:
platform/android/res/values/custom_theme.xml:
<?xml version="1.0" encoding="utf-8"?> <resources>
<style name="Theme.NoActionBar" parent="#style/Theme.Titanium">
<!-- Depending on the parent theme, this may be called android:windowActionBar instead of windowActionBar -->
<item name="windowActionBar">false</item>
</style> </resources>
Taken from: http://docs.appcelerator.com/titanium/3.0/#!/guide/Android_Action_Bar

I just added the code below in my TiApp.xml to hide the action bar that is where the name of my app and logo of Titanium were
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="#style/Theme.Titanium"/>
</manifest>
You can hide the status bar too (where the clock, battery level, notifications, etc. are) by adding the statusbar line
<fullscreen>false</fullscreen>
<statusbar-hidden>true</statusbar-hidden>
<analytics>true</analytics>

Related

On Android the statusbar and the navigation bar are still visible while the splashscreen is showing. How to get rid of it?

This is a weird problem with Apache Cordova.
I've set up an application to be packaged for Android. Since Android 4.4 there's the immersive mode.
So when I add:
<preference name="Fullscreen" value="true" />
to config.xml and start the application, I can see the status bar going out of the screen to the top and the navigation bar gets out of the screen to the bottom - as expected.
As soon as I utilize Cordova's splashscreen plugin using:
cordova plugin add cordova-plugin-splashscreen
and add a splashscreen to config.xml like so:
<splash src="res/screen/android/splashScreen.png" />
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
things are a little different.
During the time the splashscreen is visible, the screen looks like this:
As you can see, the navigation and status bar are still visible.
Well, as soon as the splashscreen disappears, I can see the status/navigation bar moving out of the screen - thus it looks like now it's switching to immersive mode.
Unfortunately this messes up the layout of the application. It seems like the actual application is now put in-between the area, where the status bar and the navigation bar have been. So instead of something fullscreen I have black borders at the top and the bottom.
This looks a little something like this:
Obviously Android returns the wrong screen dimensions because the status and the navigation bar were still there. How can I force Cordova to switch to immersive mode as soon as the splashscreen is on screen?
Question: does cordova have uses the Android native's styles and Manifest(pretty sure it does)? If so you can:
Use a full screen theme/style on your activity.
On your styles.xml:
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="#style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
and then use it in Manifest.
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.NoActionBar.Fullscreen"/>

Show both logo and app name in action bar android

i have set these two lines of code to display both logo and app name in action bar, but only app name appears, like in the screenshot:
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.icon);
Do i need other code to show both? I have added this in manifest but same result:
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:logo="#drawable/icon"
I'm working on a Tabbed activity with action bar.
Can you help me? Thank you
Solved adding
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.drawable.icona);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Using logo in actionbar is disabled by default in Android 5.0 Lollipop.
Add these 3 lines in the onCreate(Bundle) method of your Activity class:
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.mipmap.ic_launcher4);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Try this one in your style.xml:
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:icon">#drawable/logo</item>
<item name="logo">#drawable/logo</item>
<item name="displayOptions">useLogo|showHome|showTitle</item>
</style>
Don't know whether this makes problems with high api levels but worked for me on API 10.
Did you run you app in emulator or real device? I think on the Design page in the fragment does not show the icon of the app when using the layout of API L or 21.(as show below)
But when you change to API 19 or inflate the fragment into tap, it shows.(as show below)

Remove icon/logo from action bar on android

I've been trying to find some way of removing the icon/logo from the action bar but the only thing I've found after an hour of searching SO, Android's documentation and Google is how to remove the title bar in whole. That is not what I want. Only want to remove the icon/logo from the title bar.
Any one know how to accomplish this? Preferably I'd like to do this in XML.
Add the following code in your action bar styles:
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item> <!-- This does the magic! -->
PS: I'm using Actionbar Sherlock and this works just fine.
If you do not want the icon in particular activity.
getActionBar().setIcon(
new ColorDrawable(getResources().getColor(android.R.color.transparent)));
If you've defined android:logo="..." in the <application> tag of your AndroidManifest.xml, then you need to use this stuff to hide the icon:
pre-v11 theme
<item name="logo">#android:color/transparent</item>
v11 and up theme
<item name="android:logo">#android:color/transparent</item>
The use of these two styles has properly hidden the action bar icon on a 2.3 and a 4.4 device for me (this app uses AppCompat).
This worked for me
getActionBar().setDisplayShowHomeEnabled(false);
Calling
mActionBar.setDisplayHomeAsUpEnabled(true);
in addition to,
mActionBar.setDisplayShowHomeEnabled(false);
will hide the logo but display the Home As Up icon. :)
Be aware that:
<item name="android:icon">#android:color/transparent</item>
Will also make your options items transparent.
//disable application icon from ActionBar
getActionBar().setDisplayShowHomeEnabled(false);
//disable application name from ActionBar
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setIcon(android.R.color.transparent);
This worked for me.
Remove or show the title using:
getActionBar().setDisplayShowTitleEnabled(true);
Remove or show the logo using:
getActionBar().setDisplayUseLogoEnabled(false);
Remove all:
getActionBar().setDisplayShowHomeEnabled(false);
you can also add below code in AndroidManifest.xml.
android:icon="#android:color/transparent"
It will work fine.
But I found that this gives a problem as the launcher icon also become transparent.
So I used:
getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
and it worked fine.
But if you are having more than one activity and want to make the icon on an activity transparent then the previous approach will work.
I used this and it worked for me.
getActionBar().setIcon(
new ColorDrawable(getResources().getColor(android.R.color.transparent)));
getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
getActionBar().setDisplayHomeAsUpEnabled(true);
I think the exact answer is: for api 11 or higher:
getActionBar().setDisplayShowHomeEnabled(false);
otherwise:
getSupportActionBar().setDisplayShowHomeEnabled(false);
(because it need a support library.)
go to your manifest an find the application tag
android:icon="#android:color/transparent"// simply add this on place of your icon
.....
...
...
Qiqi Abaziz's answer is ok, but I still struggled for a long time getting it to work with the compatibility pack and to apply the style to the correct elements. Also, the transparency-hack is unneccessary. So here is a complete example working for v8 and up:
values\styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyActivityTheme" parent="#style/Theme.AppCompat">
<item name="actionBarStyle">#style/NoLogoActionBar</item> <!-- pre-v11-compatibility -->
<item name="android:actionBarStyle">#style/NoLogoActionBar</item>
</style>
<style name="NoLogoActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="displayOptions">showHome</item> <!-- pre-v11-compatibility -->
<item name="android:displayOptions">showHome</item>
</style>
</resources>
AndroidManifest.xml (shell)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
<application android:theme="#android:style/Theme.Light.NoTitleBar">
<activity android:theme="#style/PentActivityTheme"/>
</application>
</manifest>
Go in your manifest and find the your activity then add this code:
android:theme="#android:style/Theme.NoTitleBar"
above line hide your Actionbar .
If you need to other feature you can see other options with (CLR + SPC).
The fastest way is to modify your Manifest.xml.
If for example you want to remove the logo of activity "Activity", and leave the logo in other activities, you can do the following:
<activity
android:name=".home.XActivity"
android:logo="#android:color/transparent"
android:configChanges="orientation|keyboardHidden" />
<activity
android:name=".home.HomeActivity"
android:configChanges="orientation|keyboardHidden" />
None of the above worked.
But this did the trick:
override fun onCreate() {
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
toolbar.logo = null
(removed icon from toolbar)

how to disable status bar or notification bar but not disable title bar in android?

I want to disable status bar or notification bar in android. I use android:theme="#android:style/Theme.NoTitleBar.Fullscreen" for disable it but it makes my title bar disable too. how can I only disable status bar?
Make a base activity with below code in onCreate function and extend that activity every time
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Or
you can have above code in every activity for having Title bar visible but status bar invisible.
EDIT: Just make sure you don't define any theme in your Android Manifest.
Use the full screen theme in your manifest and then
You can defined a separate layout with your title in it then use the include tag on every layout in your app.
No Title Bar No Status bar, showing Full Screen Android (Mostly used in Games)
res->values->styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="android:Theme.NoTitleBar.Fullscreen">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
Application Manifest.xml:
:
:
<application android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppBaseTheme"
>
:
:
Result: Full screen without titlebar and status bar
No Title bar showing only Phone status bar
Same file just remove ".Fullscreen"
res->values->styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="android:Theme.NoTitleBar">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
Result: It will show only Status bar without full title bar
Showing Status bar and title bar
res->values->styles.xml:
<style name="AppBaseTheme">
Result:
Try this one in your manifest file:
android:theme="#android:style/Theme.Black.NoTitleBar"

Android Tablet Application - ActionBar

We are trying to build an Android App for Samsung Galaxy Tablets. Is there a way we can increase the height of the ActionBar? We are using Android 3.1 API 12.
You can apply a custom theme to your application.
Create styles.xml in your res/values/ directory and add something like this:
<style name="CustomTheme" parent="android:style/Theme">
<item name="android:actionBarSize">#dimen/action_bar_default_height</item>
</style>
Then create dimens.xml in your res/values/ directory and add something like this:
<resources>
<dimen name="action_bar_default_height">55dp</dimen>
</resources>
Then in your application manifest set the theme of the application like this:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:logo="#drawable/ic_launcher"
android:theme="#style/CustomTheme" >
...
</application>
You will need to create a custom Action Bar.
Here is a good tutorial
Creating a custom Action bar
Also here is a good example from the dev site.
Android Action Bar

Categories

Resources