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

  • Home
  • SEARCH
  • 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 8163873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:09:58+00:00 2026-06-06T19:09:58+00:00

How to setup(in XML) that the button will have width half of screen. I

  • 0

How to setup(in XML) that the button will have width half of screen. I found only wrap content, match parent(fills whole screen) and exact amount of dp eg: 50dp.
How to set it exactly hold the screen?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
 android:weightSum="2"
>

 <Button
     android:id="@+id/buttonCollect"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_weight="1"
     android:paddingLeft="8dp"
     android:paddingRight="8dp"
     android:text="przycisk" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:text="Button" />

  • 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-06T19:09:59+00:00Added an answer on June 6, 2026 at 7:09 pm

    This can be done by having two widgets on your layout:
    use a LinearLayout and set layout_width="fill_parent" on both widgets (Button and another widget ), and set layout_weight also to the same value .
    and the LinearLayout will split the width between the two widget equally and your button will occupy half of the screen.

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:orientation="horizontal">
    
     <Button
         android:id="@+id/buttonCollect"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:paddingLeft="8dp"
         android:paddingRight="8dp"
         android:text="przycisk" />
    
    <Button
        android:id="@+id/button2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:text="Button" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to setup a web page that listens for XML document via an
I'm using jQuery to setup an Ajax request that grabs an XML feed from
I have got an application, that is getting data via XML-files. During the parsing-part
I'm having a weird issue with a button that is being shown on screen,
I want to have a Button that when clicked, removes all the checked items
I'm using a simple program that will take tallPDF xml and convert it into
In an XML layout that is a RelativeLayout I have a nested LinearLayout. Within
So I set up a new project into Eclipse and created a build.xml that
I setup a logging.xml file as shown below. This file includes output to the
I am trying to setup a wordpress xml-rpc with rails: blog = XMLRPC::Client.new(localhost/blog, /xmlrpc.php,

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.