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

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.

Related

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

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

Android theme in library project

I have a library project providing a few activities. Some are immersive, and I need the action bar to be created. On the other hand, the clients using the library must be able to customize its theme (mainly the colors).
One of my clients is using the Theme.AppCompat.Light.NoActionBar theme, which removes the action bar from my activities.
Is there a way to ensure that the action bar will be shown (so, my activities' themes have to inherit from Theme.AppCompat.Light.DarkActionBar), while leaving the colors customizable?
Programmatically creating the action bar would be fine, but I'm not sure that this is possible, right?
EDIT: It works if my client declare the library's activities in their manifest, and set a DarkActionBar theme on each. But I'd really prefer to avoid that solution, as currently they don't have to declare our activities thanks to the manifest merger.

Hiding the action bar

It is a sample on the book.
I'm trying to hide the action bar by setting the theme to Theme.Holo.NoActionBar:
<activity
android:theme="#android:style/Theme.Holo.NoActionBar"
... >
...
</activity>
However, when I tried this I get the following exception:
You need to use a Theme.AppCompat theme (or descendant) with this activity.
What does this mean? How can I get around this?
I'm new to android programming.
Thanks!
I believe this message is because you're using a compatibility library, or you've set your minimum SDK level too low. Basically the Holo theme didn't exist in the API version you're trying to maintain compatibility with.
ActionBarActivity requires a Theme.AppCompat theme as it assumes you want an Action Bar (hence its name). If you do not want an action bar, your activity should extend from FragmentActivity which contains everything but the Action Bar from ActionBarActivity. Then you can use Theme.Holo.NoActionBar without 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

ActionBarSherlock doesn't show ActionItems when using dialog theme

I am trying to update my app with the new ActionBar paradigm. I want to keep compatibility backwards though, as my largest user base is still on Gingerbread.
To that end, I am trying to integrate ActionBarSherlock into my app.
My app is designed to use the dialog theme, so when I integrated ABS, I tried to use the corresponding dialog theme as so in my AndroidManifest.xml:
<application android:theme="#style/Theme.Sherlock.Dialog" >
My ActionItems would not show up though, and only appeared as old-school menu items (meaning they were completely inaccessible on my tablet). Looking at the samples in the ABS download, I decided to try changing my app and removing the .Dialog qualifier, changing my AndroidManifest.xml to:
<application android:theme="#style/Theme.Sherlock" >
Once I did that, the menu items moved from the menu to the ActionBar, where I expected and want them to be. So it would seem that, with default conditions, ActionItems are not enabled when using the .Dialog theme.
Is there any way to enable this behavior, so that the menu items would show in the ActionBar as expected while still using the dialog theme?

Categories

Resources