Style Android ActionMode bar - android

I'm trying to style the ActionMode bar. I want the bar to remain the same except for some margin on the right (end).
<style name="GalleryActionMode" parent="#android:style/Widget.Material.ActionMode">
<item name="android:paddingEnd">56dp</item>
<item name="android:layout_marginEnd">56dp</item>
</style>
I'm not interested in the padding, but I used it as a test and the padding adjustment works. Margin, however, has no effect. I imagine this might be related to some unusual way it enters the existing layout. Is there some way to style the layout of the ActionMode bar?

I could not find a way to do this natively, but in my searching I found a great (and tiny) library that can be used as a replacement for the CAB that behaves more like a toolbar. It was easily customizable and almost plugs right into the existing CAB model.
https://github.com/afollestad/material-cab/

Related

How to apply colorControl* attributes only to the Toolbar via styles/theme without affecting remaing item styles

I'm trying to change the color of buttons and their ripples in my Toolbars without affecting the rest of the app, but no matter how many different ways I try, something in the styles "breaks".
So far I've had the best results (as in that breaks other styles the least) by setting colorControlNormal and colorControlHighlight in the root theme of my app, however any other icon that has ?colorControlNormal set for their tint will also inherit this change as well as any ?selectableItemBackgroundBorderless and the color of scrollbars.
Previous attempts that resulted in worse results (or no results at all) count with defining the toolbar style via app theme:
<item name="toolbarStyle">#style/ToolbarStyle</item>
and in the toolbar style defining the colorControl* properties
<style name="ToolbarStyle" parent="Widget.AppCompat.Toolbar">
<item name="colorControlNormal">#color/blue</item>
<item name="colorControlHighlight">#color/blue</item>
</style>
having absolutely no result whatsoever
The other attempt was made via the theme attribute directly in the Toolbar view:
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ToolbarStyle"/>
Having the result that I wanted, but also changes a lot more than what I desired; the title + subtitle heights become the same height as the toolbar, since android:minHeight is no longer being overriden, but if I override that property in the styles then the search view will lose it's vertical alignment, the back button loses its height, etc. I end up at a point where I can't fix anything else via theme/style alone.
So now I am stuck with no clues in the documentation on how I can just change the icon colors and their respective ripple colors in the Toolbar only without affecting anything else, does anyone know how to do this without having to resort to doing it programmatically?
The styles' inheritance does not allow this to happen. The only way to do this is programmatically.

Make ListView look the same despite Android version

My application uses a android.support.v7.widget.ListViewCompat and I'm trying to make the "Overscroll" effect look the same on Pre-lollipop and Lollipop.
On pre-lollipop the Overscroll has the Holo-blue color and on Lollipop and above, it uses the colorPrimary attribute.
Most related answers I find on SO are either very complicated (I think this should be a one-liner, preferable in the App theme) or "borks" the default effect on lollipop and looks wierd.
So can can I write to set the overscroll color to colorPrimary on pre-lollipop devices?
My style.xml (App Theme) file currently contains
<item name="colorPrimary">#color/my_green</item>
<item name="colorPrimaryDark">#color/my_forest</item>
<item name="colorAccent">#color/my_soil</item>
<item name="colorControlNormal">#color/my_green</item>
<item name="colorControlActivated">#color/my_forest</item>
<item name="colorControlHighlight">#color/white</item>
I also find it very strange that the colorControlHighlight color is not used when selecting items in the ListView on pre-lollipop but the default holo-orange color.
Glow is taken from R.drawable.overscroll_edge, so I guess you won't be able to replace it easily. It would be easier to replace the EdgeEffect class with custom drawable. See:
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.4_r1/android/widget/EdgeEffect.java#EdgeEffect
So maybe this is what you're looking for:
Unfortunately this is something really hidden and you won't be able to get that glow without reflection. The above screenshot was taken on Gingerbread, so if you're not afraid of hacks, it's possible. The code is rather long, so I won't paste it here. You can find the implementation in ScrollView and RecyclerView classes of Carbon. There's no ListView (it's now replaced by RecyclerView), but you should be able to get that working as well. It's a copy of Lollipop's glow set as edge effect, so it works and looks like it should.
https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/widget/RecyclerView.java

How to customize the color of the caret of the expanded-search-action-item?

Background
I've made a few adjustments to my tiny app, so that it would follow the material design guidelines better.
The problem
I have a search action item, and the action bar is blue, but when clicking the search action item, I can barely see the caret (where the text is being entered).
I would like to change it, maybe to white (like the text color).
What I've tried
I've tried looking at the code of the support library, searching for a function that will allow me to customize the caret's color, but I couldn't find a working solution.
I've tried to use "searchViewStyle" as one of the theme's items, and create a new style:
<style name="AppTheme.SearchViewStyle" parent="Widget.AppCompat.SearchView">
...
But none of what I've found seem fit for this.
The weird thing is that when using "Theme.AppCompat.Light" instead of "Theme.AppCompat.Light.DarkActionBar" , the caret's color has changed (to green).
The question
How do I change the color of the text caret of the search action item (AKA SearchView) ?
EDIT: I've found out that it's possible to set "colorControlActivated" for the toolbar, as such:
<style name="AppTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarTheme">#style/AppTheme.ActionBarTheme</item>
....
<style name="AppTheme.ActionBarTheme" parent="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="colorControlActivated">#FFffffff</item>
</style>
Seems to work, but does it affect other things, except for the caret of the search item? If so, which ones? and is it possible to affect only the caret ?
Per official design guidelines, caret should be tinted (API>21) with the reference in android:colorControlActivated (colorControlActivated through support-v7). As you discovered it is automatically tinted like so.
colorControlActivated is used by default in several widgets. As the name suggest, it will be the color of:
an activated CheckBox;
a focused EditText;
selected RadioButtons;
and so on. I can't recall all places it is used in, but if you managed to apply it to the toolbar only, it shouldn't have any other application than the widgets you put in your Menu (the SearchView for example). It could (not sure) have some impact on contextual action bars.
If you want to have full control over the caret, you could also provide your own drawable:
<item name="android:textCursorDrawable">#drawable/my_drawable</item>
This works for API>12.

KitKat Transucency just on bottom bar and just on one activity

I'm trying to make just one activity of my app overflowing behind the software keys, like this
What I already did was to put in my theme definition the following statements
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
and then enabled it on the listView I wanted to overlap
android:fitsSystemWindows="true"
android:clipToPadding="false"
What happened was that my app did overlap on status bar and button bar, but this on EVERY activity and not just on the one I put the two rows above.
Also, it messed up my activity margins: the first row of my application drawer is hidden, and the top of my main fragment as well.
I thought fitsSystemWindows was meant to solve this kind of issues, so I added it to my theme
<item name="android:fitsSystemWindows">true</item>
but nothing changed.
So the question is apparently simple: how can I get the translucent bottom bar, with one of my activities flowing behind it, without messing up the top part of my app and without (if possible) having the same effect on all other activities?
Thank you in advance to each of you fellow helpers.
As Eluvatar stated if I need to have this effect on just one activity the best thing to do is to define a custom theme and assign it just to this activity. That's what I did, I defined an empty style in styles.xml and overrided it in values-v19/styles.xml putting just
<!--<item name="android:windowTranslucentStatus">true</item>-->
<item name="android:windowTranslucentNavigation">true</item>
Then I assigned - in AndroidManifest.xml, the proper style to the activity by using
android:theme="#style/Theme.Style.I.Created.For.This.Activity"
Disabling the first row allowed the activity to just overlap the navigation bar without popping out on the status bar. Margins seem ok as well.
I hope this is going to help somebody else someday.

Action bar action button icon size

Our app uses Action Bar Sherlock, and it has a theme like such:
<style name="Theme.MyApp.Default" parent="#style/Theme.Sherlock.Light">
<item name="actionButtonStyle">#style/MyApp.SherlockActionBar.Light.ActionButton</item>
<item name="android:actionButtonStyle">#style/MyApp.SherlockActionBar.Light.ActionButton</item>
</style>
<style name="MyApp.SherlockActionBar.Light.ActionButton" parent="#style/Widget.Sherlock.Light.ActionButton">
<item name="android:maxHeight">20dp</item>
<item name="android:maxWidth">20dp</item>
</style>
Where Theme.MyApp.Default is the default theme for the app.
I need to set the icons for the action buttons (#2 on this image) to be a specific size. When I set the height/width/scaleX/scaleY/scaleType/padding properties however, the icon on the button still maintain what looks like their pixel size. The text part of the action button does seems to adhere to the setting though. Could it just be a compound drawable on a textview?
How can I set the size of the icon on the action bar?
Action bar icons for phones should be 32x32 dp.
Action bar icons are graphic buttons that represent the most important actions people can take within your app. Each one should employ a simple metaphor representing a single concept that most people can grasp at a glance.
you refer that link here
Have you cleaned your project and then run?
and you can specify action item height in main.xml(actionbar menu layout ) also though contrl space wont wrk its like normal height prperty.
whenever changing styles you have to clean and run the project
More and more evidence points to the fact that the menu on the action bar is a compound drawable. (Setting the property android:drawablePadding moves the icon from the text.) And seeing that you can't scale the image in XML for a compound drawable, this doesn't seem possible at the moment.

Categories

Resources