Skip to content

Instantly share code, notes, and snippets.

@seanKenkeremath
seanKenkeremath / Android Lollipop Widget Tinting Guide
Last active November 17, 2023 12:40
How base colors in Lollipop apply to different UI elements
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. To use the support version of these attributes, remove the android namespace. For instance, "android:colorControlNormal" becomes "colorControlNormal". These attributes will be propagated to their corresponding attributes within the android namespace for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------
* ripple effect (Lollipop only) -- "colorControlHighlight"
Status Bar:
------------
* background (Lollipop only) - "colorPrimaryDark"
@marczych
marczych / MyActivity.java
Last active April 12, 2023 12:54
This is a workaround for `android:showAsAction="withText"` not displaying text on narrow layouts e.g. in portrait on phones. This uses styles found in ActionBarSherlock so it matches the native styling. I tested it with ABS v4.4.0 but earlier versions are probably compatible.Note: This should only be used if you absolutely have to display the te…
public class MyActivity extends Activity {
...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Trigger onOptionsItemSelected for the custom menu item because it doesn't
// happen automatically.
final MenuItem item = menu.findItem(R.id.button_id);
barcodeItem.getActionView().setOnClickListener(new OnClickListener() {
@Override