I'm using navigation drawer in my application. I want to get rid of the android's robot icon from the action bar. I'm using the following lines but the logo is not disappearing.
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
Can anyone suggest me what should I do?
getActionBar().setLogo(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
Works as well.
Just add this to your activity
getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
to hide the logo add below line also
actionBar.setDisplayShowHomeEnabled(false);
See this link also Android remove app icon action bar
This will done the magic:
1.) Add the following lines into your styles.xml:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">#android:color/transparent</item>
</style>
...
2.) And don't forget to add your style into your AndroidManifest.xml (if you haven't already done it):
<application
android:theme="#style/AppTheme"
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
...
Hope this helps!
Related
I implemented a theme for my ActionBar:
<style name="MyTheme"
parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">#color/actionbar_background</item>
<item name="android:displayOptions">useLogo|showHome</item>
<item name="android:logo">#mipmap/ic_launcher</item>
<item name="logo">#mipmap/ic_launcher</item>
<item name="background">#color/actionbar_background</item>
</style>
And I applied it in AndroidManifest.xml:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/MyTheme">
...
I know that my theme works as I see a color change, however my actionbar icon never shows up. I see it only when I explicitly call this code in onCreate method of my activity:
ActionBar actionBar = getSupportActionBar();
actionBar.setLogo(R.mipmap.ic_launcher);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
I feel like it's not correct to copy-paste the same code for every activity. Please help me to solve this problem.
The new compat library doesn't use logos nor app icons in the Toolbar (former ActionBar). You should check the style guides about that: https://www.google.com/design/spec/layout/structure.html#structure-toolbars
Starting with lollipop you get new features like tinting the notification bar on this screen:
A cool new feature is that tinting which can color all ui elements like you need it for your branding.
It is better to use android.support.v7.widget.Toolbar , you can setup your app's action bar as follows:
Toolbar toolbar = (Toolbar) findViewById(R.id.apptoolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.your_app_logo);
for more info you can read at Structure Of App Bar(which was called as ActionBar)
Android action bar tabs are left-aligned by default, I want to align it the center of the action bar. Is there any way we can make it center?
I was able to center-align the actionbar by customizing my application theme
In my AndroidManifest.xml, I added a android:theme property:
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#style/CustomActionBarTheme">
...
I then added a new themes.xml file to my project, and added :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarTabBarStyle">#style/MyActionBarTabBar</item>
</style>
<style name="MyActionBarTabBar">
<item name="android:gravity">center</item>
</style>
</resources>
The tabs should now be center-aligned.
EDIT:
It works only if your actionbar is displayed on 2 lines (in portrait)
You can use the ViewPagerIndicator plugin to customize your tabs.
Hope it helps!
I understand that these properties in the manifest:
android:theme="#android:style/Theme.NoTitleBar"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
can remove the title bar.
However, I constantly check the Graphical Layout when I am modifying my app. When I look at the Graphical Layout I still see the title bar. I want to remove the title bar in a way that I don't have to see it during the development of the game.
Simple way is to put this in your onCreate():
// Java
getSupportActionBar().hide();
// Kotlin
supportActionBar?.hide()
In the Design Tab, click on the AppTheme Button
Choose the option "AppCompat.Light.NoActionBar"
Click OK.
for Title Bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
for fullscreen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Place this after
super.onCreate(savedInstanceState);
but before
setContentView(R.layout.xml);
This worked for me.try this
I was able to do this for Android 2.1 devices and above using an App Compatibility library theme applied to the app element in the manifest:
<application
...
android:theme="#style/AppTheme" />
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.NoActionBar">
...
<item name="windowNoTitle">true</item>
<item name="android:windowNoTitle">true</item>
</style>
Note: You will need to include the com.android.support:appcompat-v7library in your build.gradle file
There are two options I'd like to present:
Change the visibility of the SupportActionBar in JAVA code
Choose another Style in your project's style.xml
1:
Add getSupportActionBar().hide(); to your onCreate method.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
}
2:
Another option is to change the style of your Application. Check out the styles.xml in "app->res->values" and change
<!-- 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>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Just use this
getSupportActionBar().hide();
If you use AppCompat v7, v21
getSupportActionBar().setDisplayShowTitleEnabled(false);
Use this to remove title from android app in your Androidmainfest.xml
android:theme="#android:style/Theme.NoTitleBar"
or you can use this in your activity
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
If you have import android.support.v7.app.ActionBarActivity; and your class extends ActionBarActivity then use this in your OnCreate:
android.support.v7.app.ActionBar AB=getSupportActionBar();
AB.hide();
In the graphical editor, make sure you have chosen your theme at the top.
It's obvious, but the App Theme selection in design is just for display a draft during layout edition, is not related to real app looking in cell phone.
Just change the manifest file (AndroidManifest.xml) is not enough because the style need to be predefined is styles.xml. Also is useless change the layout files.
All proposed solution in Java or Kotlin has failed for me. Some of them crash the app. And if one never (like me) uses the title bar in app, the static solution is cleaner.
For me the only solution that works in 2019 (Android Studio 3.4.1) is:
in styles.xml (under app/res/values) add the lines:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
After in AndroidManifest.xml (under app/manifests)
Replace
android:theme="#style/AppTheme">
by
android:theme="#style/AppTheme.NoActionBar">
Title bar in android is called Action bar. So if you want to remove it from any specific activity, go to AndroidManifest.xml and add the theme type. Such as android:theme="#style/Theme.AppCompat.Light.NoActionBar".
Example:
<activity
android:name=".SplashActivity"
android:noHistory="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In your res/values/styles.xml of modern Android Studio projects (2019/2020) you should be able to change the default parent theme
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
I went one step further and had it look like this
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- 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:windowFullscreen">true</item>
</style>
This is based on the code generated from the Microsoft PWA builder https://www.pwabuilder.com/
in the graphical layout, you can choose the theme on the toolbar. (the one that looks like a star).
choose the NoTitleBar and have fun.
Just change the theme in the design view of your activity to NoActionBar like the one here
Use this Remove title and image from top.
Before:
setContentView(R.layout.actii);
Write this code:
requestWindowFeature(Window.FEATURE_NO_TITLE);
To open the Design window:
res->layouts->activity_manifest.xml
then click on the "Design" button, next to "Code" and "Split". On the TOP LEFT Corner.
Go to res/values/themes and change the third line to .NoActionBar like this in both.
<!-- Base application theme. -->
<style name="Theme.yourApp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
I tried with the following code to hide status bar but it doesn't work..
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
and to dim the bar i used
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
and it works.. Does any one know how to hide status bar on Android 4.0.4 device??
Use the following in your Manifest
<activity
android:name=".abc"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
This however will only work on phones, Tablets do not support hiding of status bar.
Try with this on your onCreate method.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
add a style and extend Theme.AppCompat.NoActionBar , and add two item.
like this
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- 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:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style
setup your application with this theme.
like this
<application
...
android:theme="#style/AppTheme"
...>
</application>
In your AndroidManifest just add it to android:theme. Either of the following lines should work for you:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
You need to specify Fullscreen otherwise your status bar will be kept and only your Title bar will disappear.
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION doesn't hide the status bar. It hides the navigation bar.
If you want to hide the status bar you should use:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
or
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Read more here:
https://developer.android.com/training/system-ui/status.html
This Solution worked with me :
1- Root your device. use the tool in this site >> www.unlockroot.com
2- call this function at application start up >> https://stackoverflow.com/a/14940667/1995361
I'm looking through the Holo.Light theme, and I can't seem to find the magic style to override to get rid of the title text that briefly shows up when my app first launches.
How can I do that?
Try:
getActionBar().setDisplayShowTitleEnabled(false);
For v.7:
getSupportActionBar().setDisplayShowTitleEnabled(false);
I think this is the right answer:
<style name="AppTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="android:displayOptions">showHome|useLogo</item>
<item name="displayOptions">showHome|useLogo</item>
</style>
I'm very new to Android so correct me if I'm wrong, but I think if you decide to use navigation tabs on the Action Bar, they seemed to not be completely left aligned because the title text color is only transparent and hasn't gone away.
<style name="CustomActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">useLogo|showHome</item>
</style>
worked for me.
Got it. You have to override
android:actionBarStyle
and then in your custom style you have to override
android:titleTextStyle
Here's a sample.
In my themes.xml:
<style name="CustomActionBar" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/CustomActionBarStyle</item>
</style>
And in my styles.xml:
<style name="CustomActionBarStyle" parent="android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">#style/NoTitleText</item>
<item name="android:subtitleTextStyle">#style/NoTitleText</item>
</style>
<style name="NoTitleText">
<item name="android:textSize">0sp</item>
<item name="android:textColor">#00000000</item>
</style>
I'm not sure why setting the textSize to zero didn't do the trick (it shrunk the text, but didn't make it go away), but setting the textColor to transparent works.
In your Manifest
<activity android:name=".ActivityHere"
android:label="">
Write this statement under
setContentView(R.layout.activity_main);
getSupportActionBar().setDisplayShowTitleEnabled(false);
if extending AppCompactActivity use getSupportActionbar() if extending Activity use getActionBar() else it may give
null pointer exception
using android:label="" in AndroidManifest.xml for activity also works but your app won't appear in Recently used apps
you have two choice:
first:
getActionBar().setDisplayShowTitleEnabled(false);
If usign getActionBar() produced null pointer exception, you should use getSupportActionBar()
Second
getSupportActionBar().setTitle("your title");
or
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().hide();
You can change the style applied to each activity, or if you only want to change the behavior for a specific activity, you can try this:
setDisplayOptions(int options, int mask) --- Set selected display
or
setDisplayOptions(int options) --- Set display options.
To display title on actionbar, set display options in onCreate()
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
To hide title on actionbar.
getSupportActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
Details here.
i use this code in App manifest
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:logo="#drawable/logo2"
android:label="#string/title_text"
android:theme="#style/Theme.Zinoostyle" >
my logo file is 200*800 pixel
and use this code in main activity.java
getActionBar().setDisplayShowTitleEnabled(false);
it will work Corectly
I tried this. This will help -
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar should be called after setSupportActionBar, thus setting the toolbar, otherwise, NullpointerException because there is no toolbar set.
Hope this helps
The only thing that really worked for me was to add:
<activity
android:name=".ActivityHere"
android:label=""
>
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().hide();
hope this will help
If you only want to do it for one activity and perhaps even dynamically, you can also use
ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(actionBar.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE);
as a workaround just add this line incase you have custom action/toolbars
this.setTitle("");
in your Activity
Use the following:
requestWindowFeature(Window.FEATURE_NO_TITLE);
While all of these are acceptable, if your activity only contains a main activity, you can edit res\values\styles.xml like so:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
I've updated parent and added the .NoActionBar property to the Light theme from Android Studios Create Blank Application Wizard.
Simply extends your java file from AppCompatActivity and do this:
ActionBar actionBar = getSupportActionBar(); // support.v7
actionBar.setTitle(" ");
In your manifest.xml page you can give address to your activity label. the address is somewhere in your values/strings.xml . then you can change the value of the tag in xml file to null.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title_main_activity"></string>
</resources>
I am new to Android so maybe I am wrong...but to solve this problem cant we just go to the manifest and remove the activity label
<activity
android:name=".Bcft"
android:screenOrientation="portrait"
**android:label="" >**
Worked for me....
I remove the default appbar and run a custom toolbar instead using Theme.AppCompat.Light.NoActionBar then add a textview or something that extend to full toolbar width using attribute layout_width=match_parent and it pushes the title out of the toolbar. If you want to do this, you must study how to make a toolbar.
ActionBar actionBar = getActionBar();
actionBar.setTitle("");