I wanna remove the app icon from my action bar
I dont want the home icon there, I want to make more room for my other icons :) Now 4 of them are aligned to the right and the fifth one only shows up on the bottom when I press the settings key
I found this answer which looks promising
Open your styles.xml file and add below codes in your Actionbar style
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item>
Problem is, I dont know what do they refer to as "your Actionbar style"
EDIT:
after having read some answers here is what I did to my manifest
<application
android:allowBackup="true"
android:debuggable="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock.Light"
android:theme="#style/CustomActionBarTheme" >
and at the last line I get this error:
Attribute "theme" bound to namespace "http://schemas.android.com/apk/res/android" was already specified for element "application".
and this is my styles.xml:
<style name="CustomActionBarTheme">
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item>
</style>
Also I've tried
mActionBar.setDisplayHomeAsUpEnabled(false);
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.setDisplayUseLogoEnabled(false);
mActionBar.setHomeButtonEnabled(false);
It only makes the home icon invisible but it is still taking the space. Why have they provided 5 non-working methods here, what is the point? Why does it have to be so frustrating.
I worked around this issue in the following way:
- removed my settings icon
- then made my Home icon look like a settings icon
Now I have to find a way to make the Home icon open up the navigation drawer
And I also have to find a way to remove the huge blank space on the right side of the Home button so my icons are evenly spread.
Related
I checked this issue, couldn't find an answer.
there are 3 places I checked that show the label on 3 separated places in my android phone or app.
Under the logo of the app
In the app processes which show's the active apps, (from that window you can close the app process)
In the most annoying place, the "splash" action bar title (It happens before the MAIN activity UI start, when it loading the activity onCreate I believe), which most of us want to get rid of usually.
The 3 places are:
<application
android:name=".Application"
android:icon="#mipmap/icon"
android:label="#string/app_name" <!-- 1--- the first place-->
android:theme="#style/AppTheme">
<activity
android:name=".LoadingActivity"
android:label="#string/app_name" <!-- 2--- the second place-->
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:label="#string/app_name"> <!-- 3--- the third place-->
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I checked on my phone (LG4 - android 5.1).
I saw that place 2 print on the action bar and the process but place 3 print on under the app icon in the phone.
BUT! when I checked in another phone (Hawaii P9 - android 6.0)
I saw place 2 printed under the app icon in the phone, unlike in LG4 which was place 3 who did this.
The main reason I actually checked it, is that I don't want the title to appear in the action bar, while I want it to appear under the app icon and in the processes.
Any help from an expert?
sorry for commenting in the answer section but that's cuz of the low reputation, will you add your onCreate method code in order to tell you how to use
.setTitle(" ");
in which you set the title blank to make the app name doesn't appear if that helps you
1) You could override the action bar , to use your custom action bar layout.
getSupportActionBar.setCustomView("your custom view");
2) If you just want to hide the title , you could set the title using
getSupportActionBar.setTitle("");
getSupportActionBar.setSubtitle("");
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("");
}
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
From the answers you gave me, I figure a way to do what I need in a way.
I changed the main launcher activity to extend from AppCompatActivity instead of Activity, that way I could use your suggerstions you listed.
(Although I still wonder how to do it with the regular Activity)
The style themes was also enough for me, and it worked in a neater way!
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/colorPrimaryDark</item>
<item name="background">#color/colorPrimaryDark</item>
</style>
<style name="MyAppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">#color/colorPrimaryDark</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">#color/colorPrimaryDark</item>
<item name="android:actionBarItemBackground">#color/colorPrimaryDark</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
This xml style, fix the selected PrimaryColor in all of the wanted places and won't show the title in the main launch activity loading actionbar, while showing it under the icon and in the processes!
First off, I'm not completely sure that Title Bar and Action Bar are the same? 2 different things?
I have an existing application that I need to maintain. In I have an activity that had a custom view as a title. What I want is to have the default title bar for the activity - the native one. I removed the custom view, and in the activity class I removed requestWindowFeature(Window.FEATURE_NO_TITLE); but the activity still doesn't show the Title bar. I've set the activity theme to android:theme="#style/Theme.AppCompat.Light". Still no Title Bar.
The activity intent is started with launchActivityForResult - don't know if that has anything to do with that.
What am I missing here? Is there a way to show it programmatically?
title-bar and action-bar is different thing.
use theme like this.
Theme.AppCompat.Light
instead of
Theme.AppCompat.Light.DarkActionBar
<style name="MyMaterialTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
and add this theme to manifest
<application
android:name="com.qwesys.ecommerce.application.AppController"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/MyMaterialTheme">
First off, I'm not completely sure that Title Bar and Action Bar are the same? 2 different things?
Yes these are 2 different things implementation wise. Action Bar is now deprecated and we use something called the toolbar.
https://developer.android.com/reference/android/widget/Toolbar.html
You can make customized toolbar https://developer.android.com/training/appbar/setting-up.html
And for your second part use startActivityForResult() and like suggested by #sagar above you use the theme to to make the toolbar appear.
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)
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)
I am looking for a way to slightly modify the default window title in an Android app for both phone and tablet. The example below is a tablet view of the title bar as standard:
I have tried implementing a custom title bar, which works but the context menu (circled in red) disappears, which I need. All I want to do is change the color of the bottom border or remove the bottom border altogether.
Is there a way to make changes whilst keeping the context menu?
Thanks
In your manifest in application tag define as :
android:theme="#style/mytheme"
Now in res/values you can define a file say theme.xml with content as :
<resources>
<style name="mytheme" parent="#android:style/Theme" >
<item name="android:_DEFAULT_BASE_COLOR_1">#XXXXXX</item>
<item name="android:windowNoTitle">true</item>
... .
</style>
</resources>
This will change the basic colour scheme of your application. Here are the color themes primarily used on Android: http://developer.android.com/design/style/color.html