I reworked my ActionBar on the ToolBar for this video tutorial, but I came across an unpleasant problem - elements from the list started to climb onto this ToolBar, this was not the case with the ActionBar. How can this problem be solved? enter image description here

activity_main.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" > <include layout="@layout/toolbar" /> <TextView android:id="@+id/averageTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|left" android:textStyle="bold" /> <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="2dp" android:drawSelectorOnTop="false" /> <com.getbase.floatingactionbutton.FloatingActionsMenu android:id="@+id/multiple_actions" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_gravity="bottom|right" android:layout_margin="16dp" fab:fab_addButtonColorNormal="#009688" fab:fab_addButtonColorPressed="#4DB6AC" fab:fab_addButtonPlusIconColor="#FFFFFF" fab:fab_labelStyle="@style/menu_labels_style"> <com.getbase.floatingactionbutton.FloatingActionButton android:id="@+id/calculateScholarshipButton" android:layout_width="wrap_content" android:layout_height="wrap_content" fab:fab_colorNormal="#009688" fab:fab_colorPressed="#4DB6AC" fab:fab_icon="@drawable/ic_assessment_white_24dp" fab:fab_size="normal" fab:fab_title="Порахувати" /> <com.getbase.floatingactionbutton.FloatingActionButton android:id="@+id/addSubjectButton" android:layout_width="wrap_content" android:layout_height="wrap_content" fab:fab_colorNormal="#009688" fab:fab_colorPressed="#4DB6AC" fab:fab_icon="@drawable/ic_create_white_24dp" fab:fab_size="normal" fab:fab_title="Додати предмет" /> </com.getbase.floatingactionbutton.FloatingActionsMenu> </FrameLayout> 

toolbar.xml

  <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primary" android:minHeight="?attr/actionBarSize"> </android.support.v7.widget.Toolbar> 
  • We need a markup code, obviously they are in RelativeLayout - Kota1921
  • @nekaneka not, I have a FrameLayout. I added the markup code, can you tell me what the problem is? - Kostya Bakay
  • one
    FrameLayout places each new View from the upper left edge of the screen, so overlapping elements occur. - pavlofff

1 answer 1

Everything just needs to change FrameLayout to LinearLayout and it will work.

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:orientation:="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > 

It will also be useful to always remember how the elements in different layouts are friendly. In LinearLayout, elements cannot overlap, but in Relative and FrameLayout, they can.

  • Thanks, I solved the problem. Put a LinearLayout and then FloatingActionButton disappeared, to fix this, I added FrameLayout in the middle of the markup and it worked. - Kostya Bakay