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

                              SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                              은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현