Search code examples
androidandroid-framelayout

How to place a button between start and centre position inside Framelayout?


I have placed 3 buttons inside of Framelayout each with layout gravity as follows:

  1. start|bottom
  2. center|bottom
  3. end|bottom

Now I want to place two additional buttons between (start and center) and (end and center). What is the best way to achieve this? I could not get 2 horizontal linear layouts on either side of center button to work and I don't intend to use BottomNavigationView.


Solution

  • You can create 2 separate Linear Layouts one for either side of the center button. The left one should have

    <LinearLayout
      android:layout_gravity="start|bottom"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="horizontal">
    
    --add 2 buttons
    
    </LinearLayout>
    

    and the right one should have:

    <LinearLayout
      android:layout_gravity="end|bottom"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="horizontal">
    --add 2 buttons
    
    </LinearLayout>
    

    The center button should be left intact in the Frame Layout.