Android text selection text color is off -
i have toolbar text color should white. however, want theme light theme.
here's how accomplish that:
activity_main.xml
<android.support.v7.widget.toolbar android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/toolbar" android:minheight="?attr/actionbarsize" android:background="@color/primary" android:theme="@style/actionbar"/>
styles.xml
<style name="actionbar" parent="theme.appcompat.light.noactionbar"> <item name="android:textcolorprimary">@color/abc_primary_text_material_dark</item> <item name="android:textcolorprimaryinverse">@color/abc_primary_text_material_dark</item> <item name="actionmenutextcolor">@color/abc_primary_text_material_light</item> <item name="android:textcolorsecondary">@color/abc_primary_text_material_dark</item> </style>
however, when select text, toolbar looks weird:
as can see, topmost toolbar's color white when should black.
so here's question: how can make topmost text selection toolbar acceptable? either text color needs change, or background color needs change. either works me.
i have tried code:
styles.xml
<item name="actionmodestyle">@android:style/theme.black</item> <item name="android:actionmodebackground">@android:color/black</item>
and code:
styles.xml
<item name="actionmodestyle">@style/textselection</item> <style name="textselection"> <item name="textcolorprimary">@color/abc_primary_text_material_light</item> </style>
but neither works.
what doing wrong?
you may have solved now, got working creating theme (in themes.xml
) , setting actionmodebackground
, similar doing in toolbar style.
<style name="lighttheme" parent="@style/theme.appcompat.light.darkactionbar"> ... <!-- toolbar --> <item name="actionmodebackground">@color/themeactionmode_light</item> ... </style>
then, once activity launches, set theme:
public class myactivity extends appcompatactivity { @override public void oncreate(bundle savedinstancestate) { this.settheme(r.style.lighttheme) super.oncreate(savedinstancestate); setcontentview(r.layout.foo); } }
Comments
Post a Comment