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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:57:54+00:00 2026-05-27T01:57:54+00:00

I have a Linear layout with vertical orientation in which I’m inserting several view

  • 0

I have a Linear layout with vertical orientation in which I’m inserting several view groups. One of them is:

<LinearLayout
   android:id="@+id/addedit_updowncontrol"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:layout_below="@+id/textView2"
   android:layout_marginBottom="5dp" 
   android:orientation="horizontal">

    <Button
        android:id="@+id/addedit_btndecrement"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_weight="0.1"
        android:text="-" />

    <EditText
        android:id="@+id/addedit_txtQuantity"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minWidth="90dp"
        android:layout_weight="0.4"
        android:layout_alignParentTop="true"
        android:inputType="numberDecimal" />

    <Button
        android:id="@+id/addedit_btnIncrement"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_weight="0.1"
        android:layout_toLeftOf="@+id/addedit_units"
        android:text="+" />

    <Spinner
        android:id="@+id/addedit_units"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
            android:layout_weight="0.4"
        android:layout_alignParentTop="true"
    android:layout_alignParentRight="true" />

</LinearLayout>

This gives me a view that looks like this (apologies for the link, I wish there was a better way). This is unacceptable as the Button does not align with the EditText.

I tried switching to RelativeLayout, which gives me something like this. This is unacceptable as the two buttons (-) and (+) are not of the same width.

I guess what I’m trying to achieve is:
(1) The baseline of the Button is aligned with the other controls in the row.
(2) The two button are of the same width.

I seem to be able to achieve (1) with RelativeLayout and (2) with LinearLayout. But not both.

Can anyone help me please?

  • 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-05-27T01:57:54+00:00Added an answer on May 27, 2026 at 1:57 am

    use

    android:gravity="center_vertical"
    

    in your linearlayout. All items will be centered

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

Sidebar

Related Questions

I have a linear layout with this form <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical
this is the layout i have: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=match_parent android:orientation=horizontal android:minHeight=?android:attr/listPreferredItemHeight> <LinearLayout android:orientation=vertical
If for example I have defined a root linear layout whose orientation is vertical:
I have a linearlayout in which i have one image view, one textview ,
I have the following XML layout for a ListActivity. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
Here's a layout: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertical> <RelativeLayout android:id=@+id/first_tv_container android:layout_width=fill_parent android:layout_height=wrap_content android:focusable=true android:background=@android:drawable/list_selector_background>
In My application XML layout, I have one Relativelayout, In which there are two
I have implemented one up button and one down button in my layout.xml which
I have a LinearLayout, which only contains one button. I want this button to
I have created a custom tab layout which look like this,I want to make

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.