Flexible button width according another buttons widthTrigger a button click with JavaScript on the Enter key in a text boxHow do I call one constructor from another in Java?<button> vs. <input type=“button” />. Which to use?How to prevent buttons from submitting formsHow to create an HTML button that acts like a link?LinearLayout problemHow to handle button clicks using the XML onClick within FragmentsHow do I play an audio file in Android?Understanding xmlns:android = URL ? (Based on an old SO post)How to add ad-mob (Advertisement banner) Top OR Bottom of the Imageview?

What makes an ending "happy"?

is it possible to change a material depending on whether it is intersecting with another object?

Contractor cut joist hangers to make them fit

Is future tense in English really a myth?

Capacitors with same voltage, same capacitance, same temp, different diameter?

2 load centers under 1 meter: do you need bonding and main breakers at both?

Is there any control character or hack to prevent simple command line tools from showing subsequent data?

Are personality traits, ideals, bonds, and flaws required?

Leaving the USA for 10 yrs when you have asylum

Is every sentence we write or utter either true or false?

Strategies for dealing with chess burnout?

Why does PAUSE key have a long make code and no break code?

What can we do about our 9-month-old putting fingers down his throat?

UK citizen travelling to France at the end of November

Why did Tony's Arc Reactor do this?

What makes things real?

Word for something that used to be popular but not anymore

The meaning of "offing" in "an agreement in the offing"

I need to know information from an old German birth certificate

The pirate treasure of Leatherback Atoll

Why does low tire pressure decrease fuel economy?

Is mountain bike good for long distances?

How does a changeling's Divergent Persona affect bard spells cast using musical instruments?

When calculating averages, why can we treat exploding die as if they're independent?



Flexible button width according another buttons width


Trigger a button click with JavaScript on the Enter key in a text boxHow do I call one constructor from another in Java?<button> vs. <input type=“button” />. Which to use?How to prevent buttons from submitting formsHow to create an HTML button that acts like a link?LinearLayout problemHow to handle button clicks using the XML onClick within FragmentsHow do I play an audio file in Android?Understanding xmlns:android = URL ? (Based on an old SO post)How to add ad-mob (Advertisement banner) Top OR Bottom of the Imageview?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I try to make 3 buttons with vertical orientation, the problem is the first button have the widest than others, How I can make two others button automatic follow the first button width?



enter image description here
Should like this >
enter image description here



Below is the example of my code:



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="THIS IS JUST A EXAMPLE BUTTON"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON 2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON 3"/>
</LinearLayout>

</RelativeLayout>









share|improve this question
































    0















    I try to make 3 buttons with vertical orientation, the problem is the first button have the widest than others, How I can make two others button automatic follow the first button width?



    enter image description here
    Should like this >
    enter image description here



    Below is the example of my code:



    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal|center_vertical"
    android:orientation="vertical">

    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="THIS IS JUST A EXAMPLE BUTTON"/>
    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="BUTTON 2"/>
    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="BUTTON 3"/>
    </LinearLayout>

    </RelativeLayout>









    share|improve this question




























      0












      0








      0








      I try to make 3 buttons with vertical orientation, the problem is the first button have the widest than others, How I can make two others button automatic follow the first button width?



      enter image description here
      Should like this >
      enter image description here



      Below is the example of my code:



      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="center_horizontal|center_vertical"
      android:orientation="vertical">

      <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="THIS IS JUST A EXAMPLE BUTTON"/>
      <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="BUTTON 2"/>
      <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="BUTTON 3"/>
      </LinearLayout>

      </RelativeLayout>









      share|improve this question
















      I try to make 3 buttons with vertical orientation, the problem is the first button have the widest than others, How I can make two others button automatic follow the first button width?



      enter image description here
      Should like this >
      enter image description here



      Below is the example of my code:



      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent">

      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="center_horizontal|center_vertical"
      android:orientation="vertical">

      <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="THIS IS JUST A EXAMPLE BUTTON"/>
      <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="BUTTON 2"/>
      <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="BUTTON 3"/>
      </LinearLayout>

      </RelativeLayout>






      java android xml button






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 7:48







      Asqa

















      asked Mar 28 at 7:29









      AsqaAsqa

      201 silver badge7 bronze badges




      201 silver badge7 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          1
















          Change your LinearLayout Like this, it will work fine



          <LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:gravity="center_horizontal|center_vertical"
          android:orientation="vertical">

          <Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="THIS IS JUST A EXAMPLE BUTTON" />

          <Button
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="BUTTON 2" />

          <Button
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="BUTTON 3" />
          </LinearLayout>





          share|improve this answer
































            0
















            This is what you can do if you'll be willing to use ConstraintLayout. You just need to tweak some parts but it'll look like how your example looks if you don't really need it look like a table.



            <?xml version="1.0" encoding="utf-8"?>
            <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button
            android:id="@+id/button"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="8dp"
            android:text="THIS IS JUST A EXAMPLE BUTTON"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

            <Button
            android:id="@+id/button2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="32dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="32dp"
            android:text="BUTTON 2"
            app:layout_constraintEnd_toEndOf="@+id/button"
            app:layout_constraintStart_toStartOf="@+id/button"
            app:layout_constraintTop_toBottomOf="@+id/button" />

            <Button
            android:id="@+id/button3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="32dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="32dp"
            android:text="BUTTON 3"
            app:layout_constraintEnd_toEndOf="@+id/button"
            app:layout_constraintStart_toStartOf="@+id/button"
            app:layout_constraintTop_toBottomOf="@+id/button2" />

            </android.support.constraint.ConstraintLayout>





            share|improve this answer



























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );














              draft saved

              draft discarded
















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392210%2fflexible-button-width-according-another-buttons-width%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1
















              Change your LinearLayout Like this, it will work fine



              <LinearLayout
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:gravity="center_horizontal|center_vertical"
              android:orientation="vertical">

              <Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="THIS IS JUST A EXAMPLE BUTTON" />

              <Button
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="BUTTON 2" />

              <Button
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="BUTTON 3" />
              </LinearLayout>





              share|improve this answer





























                1
















                Change your LinearLayout Like this, it will work fine



                <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center_horizontal|center_vertical"
                android:orientation="vertical">

                <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="THIS IS JUST A EXAMPLE BUTTON" />

                <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="BUTTON 2" />

                <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="BUTTON 3" />
                </LinearLayout>





                share|improve this answer



























                  1














                  1










                  1









                  Change your LinearLayout Like this, it will work fine



                  <LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:gravity="center_horizontal|center_vertical"
                  android:orientation="vertical">

                  <Button
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="THIS IS JUST A EXAMPLE BUTTON" />

                  <Button
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:text="BUTTON 2" />

                  <Button
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:text="BUTTON 3" />
                  </LinearLayout>





                  share|improve this answer













                  Change your LinearLayout Like this, it will work fine



                  <LinearLayout
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:gravity="center_horizontal|center_vertical"
                  android:orientation="vertical">

                  <Button
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="THIS IS JUST A EXAMPLE BUTTON" />

                  <Button
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:text="BUTTON 2" />

                  <Button
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:text="BUTTON 3" />
                  </LinearLayout>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 28 at 7:37









                  Sandeep InsanSandeep Insan

                  2601 silver badge7 bronze badges




                  2601 silver badge7 bronze badges


























                      0
















                      This is what you can do if you'll be willing to use ConstraintLayout. You just need to tweak some parts but it'll look like how your example looks if you don't really need it look like a table.



                      <?xml version="1.0" encoding="utf-8"?>
                      <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      xmlns:app="http://schemas.android.com/apk/res-auto"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent">

                      <Button
                      android:id="@+id/button"
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_marginStart="8dp"
                      android:layout_marginTop="8dp"
                      android:layout_marginEnd="8dp"
                      android:text="THIS IS JUST A EXAMPLE BUTTON"
                      app:layout_constraintEnd_toEndOf="parent"
                      app:layout_constraintStart_toStartOf="parent"
                      app:layout_constraintTop_toTopOf="parent" />

                      <Button
                      android:id="@+id/button2"
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_marginStart="32dp"
                      android:layout_marginTop="8dp"
                      android:layout_marginEnd="32dp"
                      android:text="BUTTON 2"
                      app:layout_constraintEnd_toEndOf="@+id/button"
                      app:layout_constraintStart_toStartOf="@+id/button"
                      app:layout_constraintTop_toBottomOf="@+id/button" />

                      <Button
                      android:id="@+id/button3"
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_marginStart="32dp"
                      android:layout_marginTop="8dp"
                      android:layout_marginEnd="32dp"
                      android:text="BUTTON 3"
                      app:layout_constraintEnd_toEndOf="@+id/button"
                      app:layout_constraintStart_toStartOf="@+id/button"
                      app:layout_constraintTop_toBottomOf="@+id/button2" />

                      </android.support.constraint.ConstraintLayout>





                      share|improve this answer





























                        0
















                        This is what you can do if you'll be willing to use ConstraintLayout. You just need to tweak some parts but it'll look like how your example looks if you don't really need it look like a table.



                        <?xml version="1.0" encoding="utf-8"?>
                        <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                        xmlns:app="http://schemas.android.com/apk/res-auto"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <Button
                        android:id="@+id/button"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="8dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginEnd="8dp"
                        android:text="THIS IS JUST A EXAMPLE BUTTON"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                        <Button
                        android:id="@+id/button2"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="32dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginEnd="32dp"
                        android:text="BUTTON 2"
                        app:layout_constraintEnd_toEndOf="@+id/button"
                        app:layout_constraintStart_toStartOf="@+id/button"
                        app:layout_constraintTop_toBottomOf="@+id/button" />

                        <Button
                        android:id="@+id/button3"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="32dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginEnd="32dp"
                        android:text="BUTTON 3"
                        app:layout_constraintEnd_toEndOf="@+id/button"
                        app:layout_constraintStart_toStartOf="@+id/button"
                        app:layout_constraintTop_toBottomOf="@+id/button2" />

                        </android.support.constraint.ConstraintLayout>





                        share|improve this answer



























                          0














                          0










                          0









                          This is what you can do if you'll be willing to use ConstraintLayout. You just need to tweak some parts but it'll look like how your example looks if you don't really need it look like a table.



                          <?xml version="1.0" encoding="utf-8"?>
                          <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                          xmlns:app="http://schemas.android.com/apk/res-auto"
                          android:layout_width="match_parent"
                          android:layout_height="match_parent">

                          <Button
                          android:id="@+id/button"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="8dp"
                          android:layout_marginTop="8dp"
                          android:layout_marginEnd="8dp"
                          android:text="THIS IS JUST A EXAMPLE BUTTON"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toTopOf="parent" />

                          <Button
                          android:id="@+id/button2"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="32dp"
                          android:layout_marginTop="8dp"
                          android:layout_marginEnd="32dp"
                          android:text="BUTTON 2"
                          app:layout_constraintEnd_toEndOf="@+id/button"
                          app:layout_constraintStart_toStartOf="@+id/button"
                          app:layout_constraintTop_toBottomOf="@+id/button" />

                          <Button
                          android:id="@+id/button3"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="32dp"
                          android:layout_marginTop="8dp"
                          android:layout_marginEnd="32dp"
                          android:text="BUTTON 3"
                          app:layout_constraintEnd_toEndOf="@+id/button"
                          app:layout_constraintStart_toStartOf="@+id/button"
                          app:layout_constraintTop_toBottomOf="@+id/button2" />

                          </android.support.constraint.ConstraintLayout>





                          share|improve this answer













                          This is what you can do if you'll be willing to use ConstraintLayout. You just need to tweak some parts but it'll look like how your example looks if you don't really need it look like a table.



                          <?xml version="1.0" encoding="utf-8"?>
                          <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                          xmlns:app="http://schemas.android.com/apk/res-auto"
                          android:layout_width="match_parent"
                          android:layout_height="match_parent">

                          <Button
                          android:id="@+id/button"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="8dp"
                          android:layout_marginTop="8dp"
                          android:layout_marginEnd="8dp"
                          android:text="THIS IS JUST A EXAMPLE BUTTON"
                          app:layout_constraintEnd_toEndOf="parent"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintTop_toTopOf="parent" />

                          <Button
                          android:id="@+id/button2"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="32dp"
                          android:layout_marginTop="8dp"
                          android:layout_marginEnd="32dp"
                          android:text="BUTTON 2"
                          app:layout_constraintEnd_toEndOf="@+id/button"
                          app:layout_constraintStart_toStartOf="@+id/button"
                          app:layout_constraintTop_toBottomOf="@+id/button" />

                          <Button
                          android:id="@+id/button3"
                          android:layout_width="0dp"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="32dp"
                          android:layout_marginTop="8dp"
                          android:layout_marginEnd="32dp"
                          android:text="BUTTON 3"
                          app:layout_constraintEnd_toEndOf="@+id/button"
                          app:layout_constraintStart_toStartOf="@+id/button"
                          app:layout_constraintTop_toBottomOf="@+id/button2" />

                          </android.support.constraint.ConstraintLayout>






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 28 at 7:51









                          rmanalormanalo

                          13922 bronze badges




                          13922 bronze badges































                              draft saved

                              draft discarded















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392210%2fflexible-button-width-according-another-buttons-width%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                              Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript