Not seeing action bar for every activity that isn't MainActivity - android

I am building an app that starts activities through intents. The design of my activities in XML shows an action bar but whenever I am debugging on a physical android device, every activity besides MainActivity loses the action bar.
The entire app bar disappears and the layout continues as if there isn't supposed to be one. What are some of the first places to look to fix this?
How it looks in Android Studio preview
How it looks on a physical device

check your theme you apply on activity or application.
if it has below code then it will not show you default action bar.
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
try to remove this line to get default action bar or add action bar using <android.support.v7.widget.Toolbar

I might recommend using the Toolbar instead of ActionBar to ensure you are always getting a Toolbar on the desired activity. The Android Developer Docs do a great job at explaining how to add the Toolbar to any activity.
https://developer.android.com/training/appbar/index.html

Related

Show activity below status bar without access to activity XML/code

I have used Theme.AppCompat.Light.NoActionBar in my styles.xml to remove the action bar in my Android application. In all activities, I'm including a toolbar instead.
I am using a third party library (http://kokum.io) for user login in the app. I do not have control over the activity XML or code for the login screen that the library uses for authentication. The top of this activity is going behind the status bar.
Is it possible to make the activity show up below the status bar without access to the activity code/XML?
I figured out the solution.
In AndroidManifest.xml we can specify themes specifically for each Activity.
<activity
android:name="io.kokum.integration.LoginActivity"
android:theme="#style/CustomTheme" />
This can override the app level theme specifically for this activity.
In the specific case above, I was able to use a theme that provides an action bar to fix the issue.

PhoneGap - Styles and themes in Android app

I'm building an Android app using PhoneGap, and would like to make the copy/share menu that shows up after a long click on text to overlay the app. To do so, I have to set android:windowActionBar to true. This is what docs say:
Beware that hiding and removing the action bar causes your activity to
re-layout in order to account for the space consumed by the action
bar. If your activity regularly hides and shows the action bar (such
as in the Android Gallery app), you might want to use overlay mode.
Overlay mode draws the action bar on top of your activity layout
rather than in its own area of the screen. This way, your layout
remains fixed when the action bar hides and re-appears. To enable
overlay mode, create a theme for your activity and set
android:windowActionBarOverlay to true.
So I tried to apply this theme:
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowActionBarOverlay">true</item>
</style>
</resources>
to my application:
<application
android:icon="#drawable/icono_p"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
with no success.
Is there any way to set android:windowActionBar to true in a PhoneGap application?
EDIT:
The theme is actually being applied, but it just doesn't work as expected, the bar keeps resizing the app
I am pretty sure you would have to write a plugin for that for lower android versions. I am not sure since when this function is available but on my ICS 4.0 i can just copy and share any text out of any phonegap app without declaring anything special. its a system function and it should just work the same way you would copy and share text out of a standard browser.
what are you testing it on and which version?
Solved it. The problem was that the copy/share menu is not an action bar, but a contextual action bar shown when the contextual action mode starts. So, instead of android:windowActionBar, the property to be set to true is android:windowActionModeOverlay

Android Action Bar : App Icon & Title

Is it possible to use fragment tabs on action bar with the Theme.Holo.NoActionBar theme?
I mean... I already use this theme on my layouts but apparently it is overriden since the fragments have to show up in the action bar?
What I wanted to achieve is to actually get rid of the Title and App Icon over the fragment tabs. Something similar to the Google Music app.
Is this possible?
What I wanted to achieve is to actually get rid of the Title and App Icon over the fragment tabs. Something similar to the Google Music app.
Try calling setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar, and leave the theme alone.
You can style the action bar based on your needs. I'm quite certain you can also remove the app icon and title from there. Using a NoActionbar theme by default and then recreating the action bar on your own kinda defeats the purpose of the action bar. I suggest you use a theme with action bar and then style the bar according to your needs. This page has a decent implementation.

Hide Actionbar, Show Options Menu

I have a non-market app that was built to run on a specific device. Originally, this was on a device running 2.2, but now the app is targeting a specific device on 3.1 and I am adding in support for the Action Bar.
One of the apps Activities is required to be full-screen and have hidden the status bar and the Action Bar. This is achieved using the following in the manifest:
<activity
android:name=".activity.EditorActivity"
android:label="#string/activity_edit"
android:theme="#style/Canvas">
Which references this style:
<style name="Canvas" parent="#android:style/Theme.NoTitleBar.Fullscreen">
<item name="android:windowBackground">#color/bg_white</item>
</style>
So, after moving to 3.1, the effect works, in that the Activity is fullscreen, and everything is hidden as needed, but this of course hides the options menu from populating the Action Bar.
I know that if I leave the android:targetSdkVersion="8", the options menu is shown in the bottom navigation, but this seems like a bit of a hack - is there any other way or 'best practice' for this? I basically have to set android:targetSdkVersion="12" to ensure the app works and isn't put onto older devices so this won't be a permanent solution.
I've decided to stop trying to swim upstream and have switched to using a translucent Action Bar that is overlaid - it works perfectly and is exactly what I had been doing prior to 3.x with my custom solution.
Custom Translucent Android ActionBar

Custom Title Bar with Progress in Android

I was wondering if there was any way to feature a custom title with my own drawable -- and then subsequently put a progress bar in the title layout so that it acts like the built in android progress bar.
In my code -- I want to be able to call setProgressBarIndeterminateVisibility(true) and have that display the progress bar in my custom title bar.
Is this possible?
I have set up my application theme so that it uses a custom title -- but I don't how or where to put the progress bar in that layout.
Thanks in advance.
EDIT: Right now I use my own theme that looks something like this:
<style parent="android:Theme.Light.NoTitleBar" name="BaseTheme">
<item name="android:windowBackground">#drawable/splash_bg</item>
<item name="android:windowTitleStyle">#style/TitleBackground</item>
</style>
With the title background style as :
<style name="TitleBackground" parent="android:WindowTitleBackground">
<item name="android:background">#drawable/title_bar</item>
</style>
To give everyone a better idea -- something like this.
Add this code in onCreate before any other code:
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_PROGRESS);
setProgress(xx); // Then use this to update the progress to xx amount
To turn on/off use
setProgressBarIndeterminateVisibility(false); //true to turn on.
I have used this in a login Activity, my problem is that I run most of the login async so I having problems updating the UI. But I do get the circular progress animation to display.
I have this working on a TabActivity being updated from an async call within an Activity Intent started by the TabActivity. I had to put the "requestWind...." lines in both the TabActivityand the called Activity. Also I have found using setProgress wasn't doing much, but the spinner animation was "spinning" the whole time so I'm happy.
Here is an great example of how to implement a custom title bar with a progress indicator:
http://downloadandroid.info/2010/08/creating-a-custom-titlebar/
My solution is to have an ActivityHelper class which extends Activity and includes this method as well as one to turn on or off the progress bar, then extend that class from each of my Activities.
I believe the only way to do it is to use your own custom title bar. You COULD override the android code since its open source -- but that might be a bad idea. The best thing to do is to make a title bar layout and just <include /> it in all the other layouts and maybe have a helper class to show and hide the progress bar.
In newer versions the technique of requestWindowFeature will not work. A better option would be to use the v7.widget.toolbar that google has provided. The following link gives proper detail on how to use it.
Setting up the Actionbar
http://developer.android.com/training/appbar/setting-up.html

Categories

Resources