Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8935991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:06:51+00:00 2026-06-15T10:06:51+00:00

I am using a split ActionBar to display some simple media controls. See Below:

  • 0

I am using a split ActionBar to display some simple media controls. See Below:

Media Controls with Correct Background

I used MenuItem.setActionView to override the default view for the Fast Forward and Rewind buttons because I need to detect when the user initially touches the control (to start rewinding) and subsequently releases the control (to finish rewinding). See code below:

            ImageView rewindButton = new ImageView(getBaseContext());
        rewindButton.setId(rewindViewID);
        rewindButton.setClickable(true);
        rewindButton.setImageResource(R.drawable.ic_action_rewind);
        rewindButton.setOnTouchListener(forwardBackwardListener);
        MenuItem rewindMenu = menu.findItem(R.id.menu_rewind);
        rewindMenu.setActionView(rewindButton);
        return true;

This is all working well for me but has had an unintended side effect. When I touch the fast forward or rewind button I do not get the default blue background (as shown on the skip backward control above). It displays no background at all. I tried setting the background in the onTouch handler but the background does not fill the height of the ActionBar in the same way as the default one (see example image below), it seems like there is some padding or margin in place, but I don’t know how to remove it.

Menu with Short Background

I have tried the following with no luck:

  • Setting the height of the ImageView Manually to try to fill the ActionBar
  • Returning True or False from the onTouch Handler

Does anyone know how I might resolve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:06:52+00:00Added an answer on June 15, 2026 at 10:06 am

    I came up with a workaround which was to set the background of all the items to a small radial gradient when the item is selected. The gradient is still cut off a little but it is hardly noticeable. It makes the custom and regular buttons look almost the same.

    You end up with something like this

    First I created the radial gradient in a file called res/drawable/radialbackground.xml . Notice the end color is transparent, this is important to fade the gradient into nothing so it doesn’t fill the whole rectangle.

    <?xml version="1.0" encoding="utf-8"?>
    
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    
          <gradient
            android:centerX="0.5"
            android:centerY="0.5"
            android:endColor="#00FFFFFF"
            android:gradientRadius="35"
            android:startColor="@color/Gray"
            android:type="radial"
             />
    </shape>
    

    Then I created a StateListDrawable called res/drawable/actionitembackground.xml

    <?xml version="1.0" encoding="utf-8"?>
    
    
    <selector xmlns:android="http://schemas.android.com/apk/res/android"
                      android:exitFadeDuration="@android:integer/config_mediumAnimTime" >
            <item android:state_pressed="true" android:drawable="@drawable/radialbackground" />
            <item android:drawable="@android:color/transparent" />
    </selector>
    

    Then I assigned that statelistdrawable to the backgrounds of my custom ActionViews :

    rewindButton.setBackgroundResource(R.drawable.actionitembackground);
    

    Then I altered the style for the actionbar to include this new radial fill for the regular action bar items.

    So, in values/styles.xml I added:

    <style name="Theme.MyTheme" parent="Theme.Sherlock.Light">
            <item name="android:selectableItemBackground">@drawable/actionitembackground</item>
            <item name="selectableItemBackground">@drawable/actionitembackground</item>
    </style>
    

    In my case, the base style was Theme.Sherlock.Light but you would replace that with whatever style you wanted to amend.

    Then I set that style as the style for my application in AndroidManifest.xml

    <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/Theme.MyTheme" 
            android:uiOptions="splitActionBarWhenNarrow" >
    

    This seemed easier than digging through trying to debug why the background is cut off. Perhaps I will spend more time on it another day.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple bash script where I generate some temporary files using split,
For some reason there is a problem using string.split in certain cases. It must
In python I need a logic for below scenario I am using split function
I want to split a string in Javascript using split function into 2 parts.
So I am using: fileName.Split(' '); And I am wondering if I can init
I'm using the split linux command to split huge xml files into node-sized ones.
I have made a String[] array by using String.split(.) . I am now trying
I am using JS to split my ePub chapter into pages. I wrap code
In Java, I'm using the String split method to split a string containing values
HI All, I've been using the basic split for a while - where I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.