0

I was trying to place Linearlayout that contains buttons between The ActionBar and The Tabs, I tried implement a custom actionbar that contains both The ActionBar and a horizontal Linearlayout for the buttons, but I still can't see the buttons, is there any way to do so ?

Here my custom actionBar: custom_action_bar_with_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"
         android:layout_height="130dp"
         android:orientation="vertical"
         android:background="@color/blue_buzzvibe">
    <LinearLayout
         android:layout_width="fill_parent"
         android:layout_height="60dp"
         android:background="@color/blue_buzzvibe"
         android:orientation="horizontal"
         >

         <ImageButton android:src="@drawable/icon_menu_white"
             android:id="@+id/cab_main_messages_menu"
             android:background="@drawable/top_header_butt"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:layout_weight="0.2"/>

         <TextView 
             android:id="@+id/cab_main_messages_campaign_name"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:scaleType="centerInside"
             android:text="Campaign Of the day"
             android:textColor="@color/white"
             android:textSize="18dp"
             android:gravity="center"
             android:layout_weight="1" 
             /> 
         <ImageButton android:src="@drawable/ic_plus_wh"
             android:id="@+id/cab_main_messages_propose_message"
             android:background="@drawable/top_header_butt"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:layout_weight="0.2" />
</LinearLayout>
<LinearLayout
    android:id="@+id/options_buttons_campaign"
    android:layout_width="fill_parent"
    android:layout_height="70dp"
    android:gravity="center_vertical|center_horizontal" >
        <ImageButton
            android:id="@+id/home_desc_butt"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:src="@drawable/icon_mail_alt"
            android:background="@drawable/layout_header_selector"
            />
        <View
            android:layout_width="2dip"
            android:layout_height="fill_parent"
            android:background="@color/light_gray"
            />
        <ImageButton
            android:id="@+id/msg_list_butt_details"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:src="@drawable/icon_mail_alt"
            android:background="@drawable/layout_header_selector"
            />
        <View
            android:layout_width="2dip"
            android:layout_height="fill_parent"
            android:background="@color/light_gray"
            />
        <ImageButton
            android:id="@+id/campaign_metrics"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:src="@drawable/ic_metrics"
            android:background="@drawable/layout_header_selector"
            android:clickable="true"
            />
        <View
            android:layout_width="2dip"
            android:layout_height="fill_parent"
            android:background="@color/light_gray"
        />
        <ImageButton
            android:id="@+id/people_list_butt"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:src="@drawable/social_myspace"
            android:background="@drawable/layout_header_selector"
            android:clickable="true"
            />
    </LinearLayout>

</LinearLayout>

In onCreate i call this methode to init my actionbar:

public void initActionBar(){
    mActionBar = getSupportActionBar();
    View customView =  
    getLayoutInflater().inflate(R.layout.custom_action_bar_with_menu,null);
    mActionBar.setCustomView(customView, new  
    ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, 
    ActionBar.LayoutParams.WRAP_CONTENT));//(int) (90*scale + 0.5f))); 
    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); 
    mActionBar.setDisplayShowHomeEnabled(true);

     /** Set tab navigation mode */
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
}

I wan't to make my actionbar height change dynamically, to show all my custom actionBar

Maryeme Alaoui
  • 93
  • 2
  • 13

1 Answers1

0

you can create your custom view in ActionBar ( which contains buttons) and set this custom view to ActionBar in OnCreate() method in your activity

Example:

public class YourActivity extends ActionBarActivity {

    private ActionBar actionBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        actionBar= getActionBar();
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
            actionBar.setCustomView(R.layout.custom_view);
    }
}

How to create custom view for ActionBar question

Community
  • 1
  • 1
ahmed hamdy
  • 5,096
  • 1
  • 47
  • 58
  • Yes i aleady did it, but the problem, is that my custom actionbar height is bigger then the default actionbar height. so the second linearlayout which contains button is not shown. i'm searching of a way to make my actionbar heigh increase automatically or programmatically. i will make a copy of my code if that will help you to understand my problem. Thank you – Maryeme Alaoui Sep 01 '14 at 15:49
  • custom view which I mean not override layout of `ActionBar`. I mean set a custom view for space after home icon of application, like this question -> http://stackoverflow.com/questions/12883732/how-to-display-custom-view-in-actionbar. just want to put `TextView` into `ActionBar` – ahmed hamdy Sep 02 '14 at 10:34
  • I had use custom view just for put `ImageView` in center of `ActionBar`, I also use Menu view in `ActionBar` to put another `ImageView` refer to Search icon – ahmed hamdy Sep 02 '14 at 11:34
  • 1
    Yes i understand what did you mean.. but it's not what i want. Thank you for your help. i still searching of the solution yet. – Maryeme Alaoui Sep 03 '14 at 17:22