I want to delete the confirm button that appears on left side of CAB when my app si in selection mode. Or replace it with a back button.
I have a single selection mode, so, in contextual action bar I need only title, and a back button.
I follow android tutorial and all work fine, but now how can I remove default confirm ?
You can change the icon on the top left by changing it in the theme.
If you styles.xml, create a new theme if you don't have one already.
<style name="Theme.Custom.Light" parent="Holo.Theme.Light">
<item name="android:actionModeCloseDrawable">#drawable/ic_menu_checkmark</item>
</style>
You can put in any drawable here. Just tried it and it worked.
Related
I'd like to know what's the name of the part on top of the action bar (where the time is displayed alongside the battery, wifi, etc), and how can its color be changed ?
Thanks !
That's the status bar.
Just add colorPrimaryDark item to your theme in styles.xml
<item name="colorPrimaryDark">#color/primary.dark</item>
I have 2 types of fragments between which I want to switch. Each time I create new instance of fragment I need.
In the first fragment I need to have clickable home icon so I set the appropriate (setDisplayShowHomeAsUpEnabled) display option to true and home icon starts look like an up. In the second one I don't need it so I set the appropriate display option to false and it stops looking as up. I'm listening to clicks on the action bar icon in parent activity.
The issue is that after second fragment is shown once the next time I show first fragment home icon remains clickable while it doesn't look like an up. The question is why is it clickable if currently visible fragment set it to not look like an up button?
I'm using appcompat-v7 library.
Please set the home buttom eanabled to false as well.
getSupportActionBar().setHomeButtonEnabled(false);
Lemme know if this works. :)
EDIT - One more way, but I am not sure on this.
You can set styles for your ActionBar title and over there you can set it as non-clickable as.
<item name="titleTextStyle">#style/TitleTextStyle</item>
and here is TitleTextStyle,
<!-- action bar title text -->
<style name="TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
<item name="android:clickable">false</item>
</style>
Remember to do this for support library as well. Try and see if it does the trick.
In my android app, in the Action Bar, next to the < image is an icon. I want to make it invisible/gone ondemand dynamically. How do I do that? The icon is actually defined as follows (this should help you realize where in the action bar I am talking about).
<style name="MyAppName.LogoTheme.LogoActionBar" parent="MyAppName.Theme.ActionBar">
<item name="android:displayOptions">showHome|homeAsUp</item>
<item name="android:icon">#drawable/my_icon</item>
I tried the following, but nothing.
this.getActionBar().setDisplayHomeAsUpEnabled(false);
this.getActionBar().setLogo(null);
this.getActionBar().setDisplayUseLogoEnabled(true);
In Java, call setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar.
I am using Action Bar Sherlock for compatibility with earlier versions of Android. My objective is to not display the app title in the action bar, but to show a logo on the left and a couple of action buttons on the right. In my styles, I am using these options for the action bar:
<style name="MyActionBarStyle" parent="Sherlock.__Widget.ActionBar">
<item name="background">#drawable/toolbar</item>
<item name="displayOptions">showHome|useLogo</item>
<item name="android:background">#drawable/toolbar</item>
<item name="android:displayOptions">showHome|useLogo</item>
</style>
Everything works as hoped for on Android 2.3. On my Android 4.0.4 test phone, however, the action bar takes up the entire screen, with the app logo on the left, the action buttons on the right, but these are all centered vertically on the screen instead of residing at the top. The gradient for the toolbar, which is actually a very small pic dimensionally, occupies the entire screen (besides the status bar). The rest of the activity below the action bar is not visible.
If I remove showHome from the displayOptions above, the action bar no longer takes up the whole screen. But my logo is now gone. What do I need to do to get this working properly for Android 4?
Thanks in advance for any help.
I determined that this issue is not a problem with ActionBarSherlock, just with Android 4 in general. There seems to be a combination of options that causes this behavior to happen. I couldn't find a satisfactory solution with styles but was able to get the desired behavior in code.
After integrating the ActionBarSherlock in my android app I noticed that the dropdown menu that drops when the user hits the overflow button differs between 2.* and 4.*.
I have successfully customize this dropdown menu for 2.* with the right colours, but the dropdown menu in 4.* is displayed with white color andblack text and nothing that I do seems to modify this menu.
Do I need to do anything special to customize this dropdown menu in 4.*? it is even possible?
Thanks
When you add a style for ABS, you must be sure to also include the proper Android tags. E.g.
Not just
<item name="actionBarStyle">#style/ActionBar</item>
But
<item name="actionBarStyle">#style/ActionBar</item>
<item name="android:actionBarStyle">#style/ActionBar</item>
The former only controls ABS, and the library uses the standard Action Bar on 4.x.