如何更改ActionMode的布局或背景?有actionMode.getCustomView();方法,但总是返回null。有什么建议吗?
发布于 2013-07-22 20:23:07
您可以使用此属性通过styles.xml更改它
<item name="android:actionModeBackground">@drawable/actionbar_background</item>
<item name="actionModeBackground">@drawable/actionbar_background</item>尚不支持ASAIK以编程方式对其进行更改
发布于 2014-04-04 14:50:01
我想把这个答案说得更清楚。首先在您的可绘制文件夹中创建自定义背景"storage_list_header_shape.xml“。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="270"
android:startColor="@android:color/holo_orange_light"
android:centerColor="@android:color/holo_orange_dark"
android:endColor="@android:color/holo_orange_light" />
<size android:height="3dp" />
</shape>其次,在style.xml中创建自定义样式
<style name="customActionModeTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionModeBackground">@drawable/storage_list_header_shape</item>
</style>第三,在你的清单中调用样式。
<activity
android:name="com.javacafe.activities.Main"
android:launchMode="singleTop"
android:screenOrientation="sensorLandscape"
android:theme="@style/customActionModeTheme" >
</activity>发布于 2013-07-22 20:25:17
如果要更改ActionMode的背景,应该使用actionMode.setCustomView(View yourView),然后可以将yourView变量传递给该方法。
https://stackoverflow.com/questions/17787432
复制相似问题