Android: SplitActionBar - android

I'm using the Holo.Light Theme for the ActionBar. I'm using the splitActionBar Option via android:uiOptions="splitActionBarWhenNarrow" in my manifest. I also use a custom layout for the ActionBar:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="noTitle" parent="android:Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBarStyle</item>
</style>
<style name="MyActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions"></item>
<item name="android:height">0dip</item>
</style>
</resources>
The thinking behind this one is, to not "show" the top actionbar. So I basically see the "bottom" actionbar and resize the "top" actionbar to zero. This works perfectly fine, but now the problem:
If I use the app on the new devices e.g. Galaxy S4 android 4.2.2 it resizes the "top" and "bottom" actionbar to zero. How can I only resize the top actionbar to zero, so I don't see the title on the new devices.

Related

Android translucent status bar but non-translucent navigation bar (if present)

I'm trying to create splash screen for android application with this article: Splash Screens the Right Way. As article says, I created LayerDrawable with two layers: background bitmap and logo (also bitmap). Logo need to be located at the bottom of screen with indent 32dp, for example. Here my drawable:
<item
android:drawable="#drawable/splash_image" />
<item
android:id="#+id/logo"
android:bottom="#dimen/margin_splash">
<bitmap
android:gravity="bottom|center"
android:src="#drawable/logo_green" />
</item>
I pointed this drawable as android:windowBackground param in my splash activity theme. I also want to have transparent status bar when splash screen is shown on devices where this feature is supported (API >=19), so I created two resource files for different android versions and in values-v19\styles.xml I pointed flag android:windowTranslucentStatus as true. Here my values/styles.xml and values-v19/styles.xml:
values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/bg_splash</item>
</style>
</resources>
andvalues-v19/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/bg_splash</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
But on some Android devices with Soft NavigationBar my logo is overlapped by it.
I tried to point android:windowTranslucentNavigation flag as false but without success.
Is any way to make Android Soft NavigationBar transparent together with
transparent status bar, or I need detect Soft NavigationBar availability in onCreate method of my splash activity and update my LayerDrawable by adding bottom indent for logo to the height of NavigationBar?
Thanks.
Did you try this?
<item name="android:navigationBarColor">#android:color/transparent</item> <item name="android:windowTranslucentStatus">false</item> <item name="android:windowTranslucentNavigation">false</item>
Also you can a little bottom padding to your bitmap item in the layer drawable.
I encountered the same problem and solved this problem by setting the following attributes.
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
This attributes is set to values-v21 directory.

How to get orange button text, white tab indicators and black titles with Appcompat

On android 7 (nexus phone) the title in my context menu appears white. I would expect it to be black as it is on all other devices I tested. The rest of the app looks good.
Update:
I figured out that the colorAccent is the culprit (AppCompat styles various things based on that). I set it to white in a child theme because the tabBar needs to have white tab indicators.
So now the issues is that I need white tab indicators in the actionbar, black titles in dialogs and context menus and Orange text on buttons styled with the Button.Borderless.Colored style. All of these seem to be controlled with colorAccent. I can make a seperate style for the buttons. But the styles of the dialogs and tab indicators are still conflicting. For legacy reasons I cannot use the new toolbar with a tablayout (That one is stylable) but have to use the Actionbar. Any ideas?
White title in context menu screenshot:
Thanks in advance!
Theme:
<resources>
<!-- default theme -->
<style name="Theme.MyApp" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Remove actionbar -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!-- Basic coloring -->
<item name="colorPrimary">#color/MyAppOrange</item>
<item name="colorPrimaryDark">#color/MyAppOrangeDark</item>
<item name="colorAccent">#color/MyAppOrangeDark</item>
<!-- AppCompat dialog themes -->
<item name="dialogTheme">#style/Theme.MyApp.Dialog</item>
<item name="alertDialogTheme">#style/Theme.MyApp.Dialog.Alert</item>
///// Tried this with a custom style but that just f*cked up my tabs...
<item name="actionBarTabStyle">#style/CustomActionBarTabs</item>
</style>
<!-- Alert and dialog styles -->
<style name="Theme.MyApp.Dialog" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">#color/MyAppOrange</item>
<item name="colorPrimaryDark">#color/MyAppOrangeDark</item>
<item name="colorAccent">#color/MyAppOrangeDark</item>
</style>
<style name="Theme.MyApp.Dialog.Alert" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorPrimary">#color/MyAppOrange</item>
<item name="colorPrimaryDark">#color/MyAppOrangeDark</item>
<item name="colorAccent">#color/MyAppOrangeDark</item>
</style>
</resources>
Djangow, you need to define a new style that with the text color as the specific color you want and then set that style in the app theme you want to use. See this link for the exact coding needed.
UPDATE: Djangow, I apologize. I looked into it and found that you have to add this line <item name="android:actionMenuTextColor">#color/your_color</item> to the main App theme. I found the answer here. Hope that helps

Android ActionBar Tabs background color split mode

Hee,
First of all I want to say that I am using ActionBarSherlock (the screenshots are taken on a Samsung Galaxy S3).
I have an actionbar with a tabbar in it, I want that the tabbar has a grey color when it is splitted (the tabbar is underneath the actionbar) and a transparant color (or same color as actionbar background) when the tabbar is inside the actionbar.
Here is a little code snippit of my styles.xml:
<style name="Theme.OSP.Light" parent="#style/Theme.Sherlock.Light">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="actionBarTabBarStyle">#style/Widget.Styled.ActionBar.TabBar</item>
<item name="android:actionBarTabBarStyle">#style/Widget.Styled.ActionBar.TabBar</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:background">#F0F0F0</item>
<item name="background">#F0F0F0</item>
</style>
<style name="Widget.Styled.ActionBar.TabBar" parent="Widget.Sherlock.Light.ActionBar.TabBar">
<item name="android:background">#E0E0E0</item>
<item name="android:gravity">center</item>
</style>
Below are some screenshots to make my question more clear.
Landscape (actionbar not splitted). This is not OK, the tabbar should have the same color as the actionbar, but instead it has the same grey color:
Portrait (actionbar splitted). This is OK, the tabbar has a grey color in this state:
I've found a wonderful website were you can generate an android theme in seconds! This solved all my problems:
http://jgilfelt.github.com/android-actionbarstylegenerator/
EDIT
Also see the following link for a working answer: Change ActionBar Tabs background color

How do I keep ActionBar items' background the same while changing the app's main background?

I am trying to change the background of the app, but when I do the below (sdk 14) the items in the actionbar also change to match the new background color. The actionbar itself has the correct background, but the items in the actionbar do not. I was able to get the actionbarmenuitems to be correct, but the title and search view and home icon and back button all have the background set on the custom theme. What am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Holo.DarkerBack" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:background">#color/background</item>
<item name="android:actionBarStyle">#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse</item>
</style>
</resources>
Try replacing
<item name="android:background">#color/background</item>
with
<item name="android:windowBackground">#color/background</item>

Android: ActionBar Hidden

I have an old app which now when run on tablets like the Xoom, hides the ActionBar. The app was written before the ActionBar existed so some old code is hiding the actionbar.
What in an old app can hide the ActionBar? I need to change it so that the ActionBar and therefore the menu can be shown:
Here's my very simple Theme:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="android:Theme.Black">
<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#android:color/transparent</item>
</style>
<style name="TextViewStyled" parent="#android:style/Widget.TextView">
<item name="android:textStyle">normal</item>
<item name="android:lineSpacingMultiplier">1.22</item>
</style>
</resources>
And here's the only window settings I use:
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_RIGHT_ICON);
Using android:Theme.Black as your theme parent is what's "hiding" the action bar. The Holo and DeviceDefault theme families include an action bar by default, but the legacy theme family (from which Theme.Black derives) does not.
Use a theme declared with the same name "MyTheme" in res/values-v11/themes.xml with a parent of #android:style/Theme.Holo. This version of the theme will be used on devices running API level 11 (Android 3.0, where Holo and the action bar were introduced) or newer. You should similarly use Widget.Holo.TextView instead of Widget.TextView when declaring a custom view style to work within the Holo theme.

Categories

Resources