Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action mode close button text color

I see to set the text color of the action mode "done" / "close" button. This is what I've tried:

<item name="android:actionModeCloseButtonStyle">@style/ActionModeCloseButton</item>
....
<style name="ActionModeCloseButton" parent="android:style/Widget.Holo.ActionButton.CloseMode">
    <item name="android:textColor">@android:color/white</item>
</style>

but is has no effect.

enter image description here

Note that on JB, it's enough that I make the ActionModeCloseButton style's parent the regular holo theme. It works fine there (without the textColor setting even).

Any ideas?

like image 907
Jeffrey Blattman Avatar asked Sep 28 '12 17:09

Jeffrey Blattman


1 Answers

First of all, the textview "Done" is only visible on large devices. Checkout action_mode_close_item.xml in the Android source. So the android:actionModeCloseButtonStyle only applies to the containing view and not the imageview and the textview.

Luckily, the android engineers used publicly accessible attributes to styles the childviews.

  • Use android:actionMenuTextColor to change to textColor of the TextView.
  • Use android:actionModeCloseDrawable to change the drawable of the ImageView

Example:

<style name="MyTheme">
    <item name="android:actionMenuTextColor">#ff000000</item>
    <item name="android:actionModeCloseDrawable">@drawable/my_close_drawable</item>
</style>

Below is a copy of the action_mode_close_item.xml in the layout-large-folder where you can see how the layout is build.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/action_mode_close_button"
        android:focusable="true"
        android:clickable="true"
        android:paddingStart="8dip"
        style="?android:attr/actionModeCloseButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginEnd="16dip">
    <ImageView android:layout_width="48dip"
               android:layout_height="wrap_content"
               android:layout_gravity="center"
               android:scaleType="center"
               android:src="?android:attr/actionModeCloseDrawable" />
    <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center"
              android:layout_marginStart="4dip"
              android:layout_marginEnd="16dip"
              android:textAppearance="?android:attr/textAppearanceSmall"
              android:textColor="?android:attr/actionMenuTextColor"
              android:textSize="12sp"
              android:textAllCaps="true"
              android:text="@string/action_mode_done" />
</LinearLayout>
like image 131
Jelle Avatar answered Nov 11 '22 12:11

Jelle