我在尝试更改上下文栏操作栏时遇到问题。所以我把它设置好并且工作正常,但我似乎无法改变左上角的文字颜色。我为驾驶室设置了一个自定义主题,但它没有帮助。
<style name="Widget.ActionMode" parent="@android:style/Widget.Holo.Light.ActionMode">
<item name="android:textColor">@android:color/white</item>
</style>
我的CAB看起来与此链接中的类似,但文字颜色(左上角)由于某种原因是黑色的。
http://androidperspective.files.wordpress.com/2013/04/nexus-4-flat.png
答案 0 :(得分:2)
Yes You can do that...
For changing text color you have to follow steps...
1) create XML file containing only Textview
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contextualAB_Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white" />
2)Now, replace following line of code with your code.
Original :
mActionMode.setTitle(String.valueOf(mSelectedCount) + " selected");
Replace with :
TextView tv = (TextView) getLayoutInflater().inflate(R.layout.contextual_title, null);
tv.setText("Contextual Action Bar");
mActionMode.setCustomView(tv);
You can replace your color with @android:color/white