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

The Archive Base Latest Questions

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

I wanted to create a custom bottom button bar layout, I’ve created a xml

  • 0

I wanted to create a custom bottom button bar layout, I’ve created a xml file :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="0dp" >

<Button
    android:id="@+id/media_menu_button"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_margin="0dp"
    android:layout_weight="1"
    android:text="@string/media_menu_button" />

<Button
    android:id="@+id/scenario_menu_button"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_margin="0dp"
    android:layout_weight="1"
    android:text="@string/scenario_menu_button" />

 <Button
    android:id="@+id/rooms_menu_button"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_margin="0dp"
    android:layout_weight="1"
    android:text="@string/rooms_menu_button" />

<Button
    android:id="@+id/shortcut_menu_button"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_margin="0dp"
    android:layout_weight="1"
    android:text="@string/shortcut_menu_button" />

as you can see I’ve given all the buttons width 0dp and weight of 1. then, I’ve created a class that extends the linear layout class :

public class BeLightBottomBar extends LinearLayout implements OnClickListener {
private LayoutInflater mInflater; 
private Context contexnt;

private Button mShortcutMenuButton;

private Button mRoomsMenuButton;

private Button mScenarioMenuButton;

private Button mMediaMenuButton;

public BeLightBottomBar(Context context, AttributeSet attrs) {
    super(context, attrs);

    //inflate the view
    this.contexnt = context;
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    LinearLayout barView = (LinearLayout) mInflater.inflate(R.layout.belight_bottombar, null);
    addView(barView);

    //get all the instances of the components of the bar
    mShortcutMenuButton = (Button) barView.findViewById(R.id.shortcut_menu_button);
    mRoomsMenuButton = (Button) barView.findViewById(R.id.rooms_menu_button);
    mScenarioMenuButton = (Button) barView.findViewById(R.id.scenario_menu_button);
    mMediaMenuButton = (Button) barView.findViewById(R.id.media_menu_button);

    //set this as a click listener
    mShortcutMenuButton.setOnClickListener(this);
    mRoomsMenuButton.setOnClickListener(this);
    mScenarioMenuButton.setOnClickListener(this);
    mMediaMenuButton.setOnClickListener(this);
    ... 
    ...
    ...
  }

the problem is when i add this class to the main activity xml

<belight.homecontrol.components.BeLightBottomBar
    android:id="@+id/button_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_margin="0dp"
    android:padding="0dp" />

the weight stops working, all the buttons are different. and I don’t know why !?
if I just copy paste the bottom’s bar xml code to the main xml file it works fine, the problem only occurs when using it as a whole.

P.S.
Is it a good practice to create a component this way? Or maybe I’m doing something wrong?

Thanks,
Dan

  • 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-11T09:14:47+00:00Added an answer on June 11, 2026 at 9:14 am

    Hmm, I’ve never seen a layout inflated exactly that way. There may be something funky going on with it, try this one-line approach instead:

    //inflate the view
    this.contexnt = context;
    LayoutInflater.from(context).inflate(R.layout.belight_bottombar, this);
    
    //get all the instances of the components of the bar
    ....
    

    That’s what I use for any custom components. I’ve done plenty of LinearLayouts with weights attached like this, so there shouldn’t be any issue with that. Makes it read cleaner too, since it cuts three lines down to one.

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

Sidebar

Related Questions

I created a Vaadin Project, then wanted to create a Custom composite and display
I wanted to create a page with a simple button which runs away from
I wanted to create one js file which includes every js files to attach
I've always wanted to create custom components in Java, or customize existing ones, but
I wanted to create a custom combo box like this (as in MS Word),
I created a custom view class because I wanted to have a status item
I wanted to create a button that had an image and a textblock as
I wanted to create a notification without the icon in the status bar (the
I have decided that I wanted to create some custom dialog classes that could
I wanted to create a plugin to batch manage posts' custom field data. 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.