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 8807415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:21:47+00:00 2026-06-14T02:21:47+00:00

Does anybody know how to easily implement an action bar with two stretched buttons?

  • 0

Does anybody know how to easily implement an action bar with two stretched buttons?

Here is an example of the Google calendar app:

enter image description here

Thank you!

  • 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-14T02:21:49+00:00Added an answer on June 14, 2026 at 2:21 am

    If you rather have this in the ActionBar for whatever reason, one way to achieve this is by using a custom view on the Action bar. Within you Custom View’s layout then worry about setting up the buttons width.

    Telling the activity to use a custom view for the action bar:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);   
        final ActionBar ab = getActionBar();
        ab.setDisplayShowHomeEnabled(false);
        ab.setDisplayShowTitleEnabled(false);     
        final LayoutInflater inflater = (LayoutInflater)getSystemService("layout_inflater");
        View view = inflater.inflate(R.layout.action_bar_edit_mode,null); 
        ab.setCustomView(view);
        ab.setDisplayShowCustomEnabled(true);
    }
    

    layout/action_bar_edit_mode.xml can then look something like:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="fill_horizontal"
        android:orientation="horizontal" >
        <LinearLayout 
            android:layout_alignParentLeft="true"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">
    
            <Button
            android:id="@+id/action_bar_button_cancel"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"           
            android:layout_weight="1"
            android:text="Cancel" />
    
            <Button
            android:id="@+id/action_bar_button_ok"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"           
            android:layout_weight="1"
            android:text="Ok" />
        </LinearLayout>    
    </RelativeLayout>
    

    Hope it helps someone!

    Note: I realize the ugly nesting layouts here and normally I wouldn’t recommend this but for some reason the actionbar’s own layout refuses to let the LinearLayout take up the entire width on its own. Normally you should avoid nesting layouts unnecessarily like this!
    Perhaps if someone sees this they can point us to a better solution?

    What it looks like:
    result

    EDIT: There is an excellent post by Roman Nurik where he explains a way to do this very nicely.

    EDIT 2: If anyone is curious, the correct way to lay out the buttons so that they expand the width of the actionbar without the need to nest your layouts like I did above, is to set the custom view with the proper layout parameters that allows its component to match the parent group.

    Essentially:

    actionBar.setCustomView(view,new ActionBar.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know why my getAltitude in the following always returns 0? package com.example.helloandroid;
Does anybody know how to (easily) rename an existing grails application? I'm running into
Does anybody know if it is possible to have a storyboard in an App
Does anybody know the memory difference between these two? Or how one would figure
Does anybody know how to parse a string below to get these two strings:
Does anybody know a Python module to easily extract temporal expressions such as 12/01/2011
Does anybody know why this function, when passed an invalid date (e.g. timestamp) to
Does anybody know if the CUDA library 'Thrust' can generate random numbers on the
Does anybody know how to programmatically disable the keyboard individual letter pop-up? (This blue
does anybody know how to insert code into lyx? just like what is available

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.