Search code examples
androidandroid-linearlayoutimagebuttonandroid-imagebutton

How can I create this layout that spans multiple rows using Android LinearLayout?


What can I do to just bring up these ImageButtons in this layout with the LinearLayout? I've already tried it with the TableLayout, but it doesn't worked for me because not all rows with ImageButtons as its children were displayed.

Layout


Solution

  • This can be achieved by nesting layouts inside layouts. Hint;

    <LinearLayout
     android: orientation = "vertical">
         <LinearLayout
          android: orientation = "horizontal">•
              <Button.../>
              <Button.../>
              <Button.../>
              <Button.../>
         </LinearLayout>
    
         <LinearLayout
          android: orientation = "horizontal">
              <Button.../>
              <Button.../>
              <Button.../>
              <Button.../>
         </LinearLayout>
         <RelativeLayout>
              <LinearLayout
               android: orientation = "horizontal"
               android: id = @+id/"abc">
                  <Button.../>
                  <Button.../>
                  <Button.../>
              </LinearLayout>
              <LinearLayout
               android: orientation = "horizontal">•
                  <Button.../>
                  <Button.../>
                  <Button.../>
              </LinearLayout>
                  <Button...
                   android: layout_toRightOf=" @id/abc"/>
         </RelativeLayout>
    
    
    </LinearLayout>
    

    You can also nest layouts in ConstraintLayout. It all depends on the way you want to achieve the result