android and emulator remove actionBar - android

hello i have to remove actionBar into an activity, this is my style:
<style name="AppTemaGiornoFullScreen" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
this work very well into android 4x, but into an 2x emulator actionBar is always visible.. why?

You can hide it programatically from the Activity itself using this line of code in your
OnCreate method after setContentView line
getActionBar().hide();
If you are using tabs activity, use this:
getParent().getActionBar().hide();
This is a similar question .. Link
If you are asking about hiding the TitleBar programatically..Add the following lines on your onCreate before setContentView line
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
This is a similar question .. Link

Related

Not able to set transparent background for Popup Window Activity

I am following this particular example to create a popup window activity but when I click on a button to open this activity, the background is not semi-transparent as mentioned in the example. I am new to android kotlin development so I am not able to figure this out on my own. Let me know what I am doing wrong.
EDIT: This link tells a different method but working fine.
You can customize the translucent theme of your activity, in your "AndroidManifest.xml" file.
<activity
android:name=".ui.PopUpWindow"
android:theme="#style/AppTheme_translucent" />
and in your "styles.xml" file.
<style name="AppTheme_translucent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowBackground">#color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
I travel the code and did not see setContentView() method for PopupWindow activity. Please set content view for the activity by calling the method inside PopupWindow's onCreate()

You cannot combine custom title with other title features

In my application, I'm using ActionBarSherlock library. Also I'm using a custom title bar.
Here goes my onCreate:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main_tab);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
And in my styles.mxl
<style name="MyTheme" parent="Theme.Sherlock">
<item name="android:background">#ff888888</item>
<item name="android:windowNoTitle">false</item>
<item name="android:windowTitleSize">50dp</item>
<item name="android:windowTitleBackgroundStyle">#style/windowTitleBackgroundStyle</item>
</style>
<style name="windowTitleBackgroundStyle">
<item name="android:background">#00688B</item>
</style>
In Manifest file i am using MyTheme for the activity.
android:theme="#style/MyTheme"
This code properly works with lower android version (I have tested with GB2.3.5). But when i tested with ICS, its crashing with the Below error:
"You cannot combine custom title with other title features"
I went thoroughly in StackOVerflow discussions, but unable to resolve the issue.
solutions tried:
1) false
2) there is no values-v11 folder
I received the same exception.
Here is what I found: In newer versions of Android, the framework will use the Window.FEATURE_ACTION_BAR feature whenever the Holo theme is selected. The framework throws the exception whenever an app calls setFeatureInt(Window.FEATURE_CUSTOM_TITLE) and FEATURE_ACTION_BAR has already been set.
In my case, the styles.xml file in the values-v11 folder was redefining my theme to inherit from android:Theme.Holo. When I attempted to run my app on a Android 3.0 or above - it crashed because Holo uses the ActionBar by default. The fix was simple. Turn the ActionBar off when using Holo. Here is the revised values-v11\styles.xml changes:
<style name="AppBaseTheme" parent="android:Theme.Holo.NoActionBar">
<!-- API 11 theme customizations can go here. -->
</style>
I had the same problem and solved it:
THE ROOT CAUSE:
In the Manifest, I copy pasted this tag by mistake from my splash screen into my activity: #android:style/Theme.NoTitleBar
The fatal exception occured when I also requested a FEATURE_CUSTOM_TITLE on my activity, causing the conflict.
SOLUTION:
To fix it, I checked these 3 things:
1)OnCreate method:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_login);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_titlebar);
}
2)INSIDE your manifest.xml:
Make sure a line such as these ONLY appears in a splash screen if you have one:
android:theme="#android:style/Theme.NoTitleBar
REMOVE that line from any other activity if you want a custom Bar.
In the application tag , my only theme tag is this one:
android:theme="#style/AppTheme"
In the activity tag, I have no theme tag.
3) Go to your activity's XML layout, and view it in GRAPHIC LAYOUT mode.
Maye sure your that the Theme says AppTheme (its the the you put on the manifest)
Mine said "No Title", so this was causing the problem.

Activity with action bar but without title?

How to achieve this? It seems very simple, but actually it's not easy to do it in acceptable way. I tried this:
1) in AndroidManifest I set activity theme to Theme.NoTitleBar. However, in my Activity then getActionBar() method returns null => UNUSABLE
2) I hide title programatically in my activity by calling:
actionbar.setDisplayShowTitleEnabled(false);
actionbar.setDisplayShowHomeEnabled(false);
and it helped, but there's a little delay, so I can see title bar maybe quarter of second after activity launch, then it disappears. It looks really lame.
Are there other options?
Apply a custom theme to your Activity, something like:
<style name="TestTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/TestActionBar</item>
</style>
<style name="TestActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/actionbar_background</item>
<item name="android:displayOptions"></item>
</style>
This will show the action bar with the logo, but no title.
Have u try bellow code :-
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getActionBar().hide();
setContentView(R.layout.ur activityxml);
or also try below one
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activityxml);

Custom Title bar delay

My app uses a custom titlebar created as a layout and is implemented using this format:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.my_layout);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_custom_title);
super.onCreate(savedInstanceState);
Now it did not work using the regular theme android:Theme.Light, neither did android:Theme.Light.NoTitleBar, they both resulted in a fatal exception when setContentView was called. So I created a custom style which looks like this:
<style name="MyWindowTitleBackground">
<item name="android:background">#000000</item>
</style>
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowTitleBackgroundStyle">#style/MyWindowTitleBackground</item>
<item name="android:windowActionBar">false</item>
<item name ="android:windowTitleSize">35dip</item>
</style>
However, every time the app is started there is a small delay in between the start and display of the actual layout with the custom titlebar, in this delay the default titlebar is shown with the appname in it. After about a second, when the Oncreate finishes, the custom title is loaded and shown.
Is there any way to fix this? What am I doing wrong?
Try putting
super.onCreate(savedInstanceState);
before the other lines and see if that works.
and putting
setContentView(R.layout.my_layout);
last. I seemed to remember my app crashing because I had it in the wrong order.

Custom title bar still shows original on startup

I'm using a custom title bar in my app and it all works fine except that when the app starts up, the original (standard) android title bar is shown for a brief time before it is replaced by my custom title bar.
This is not a problem when the app is already loaded in memory because the 'delay' is not apparent but if the app is not already in memory, it is very obvious.
There's nothing special about the code :
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
I thought about changing the style to have no window title and just include my custom title in the top of the layout but that doesn't seem right.
Thanks for any pointers.
Thomas Devaux has posted a smart solution. It worked in my app
Change the windowTitleBackgroundStyle to use color “#android:color/transparent”.
Also create a style for the text “android:windowTitleStyle” and set its “android:textColor” >to transparent as well.
For completeness to Lluis' answer, here's the full code you need to hide the default-title before the custom-title is initiated:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="CustomWindowTitleStyle">
<item name="android:textColor">#android:color/transparent</item>
</style>
<style name="CustomTheme" parent="#android:style/Theme.Holo">
<item name="android:windowActionBar">false</item>
<item name="android:windowTitleBackgroundStyle">#android:color/transparent</item>
<item name="android:windowTitleSize">50dp</item>
<item name="android:windowTitleStyle">#style/CustomWindowTitleStyle</item>
</style>
</resources>
add a splash screen activity before the main activity loads, should have enough time for the next one to load properly
Are you able to use an app theme to set a custom title globally for your app? See here for a pretty good example. I had a similar problem and i seem to remember going this route fixed it.

Categories

Resources