Reputation: 2343
How can we change the layout or background of an ActionMode
? there is methodactionMode.getCustomView();
but always returns null . is there any suggestion?
Upvotes: 2
Views: 3260
Reputation: 3592
I wanna make more clearer this answer. First create custom background "storage_list_header_shape.xml" in your drawable folder.
<?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>
Second, create custom style in your style.xml
<style name="customActionModeTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionModeBackground">@drawable/storage_list_header_shape</item>
</style>
Third, call the style in your manifest.
<activity
android:name="com.javacafe.activities.Main"
android:launchMode="singleTop"
android:screenOrientation="sensorLandscape"
android:theme="@style/customActionModeTheme" >
</activity>
Upvotes: 2
Reputation: 1210
if you want to change the background of an ActionMode
,you should use the actionMode.setCustomView(View yourView)
,then you can transfer the yourView
variable to the method.
Upvotes: 1
Reputation: 157467
You can change it through styles.xml with this attribute
<item name="android:actionModeBackground">@drawable/actionbar_background</item>
<item name="actionModeBackground">@drawable/actionbar_background</item>
ASAIK changing it programmatically is not yet supported
Upvotes: 7