0

我有主要的活动与标签片段..在片段我有列表视图,但是当我滚动到上底最后一个项目,该项目是由系统所覆盖的按钮:Android系统按钮重叠的ListView

screenshot

这里是我的活动XML:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.example.martin.fitnessapp.MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="@dimen/appbar_padding_top" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:popupTheme="@style/AppTheme.PopupOverlay"> 

     </android.support.v7.widget.Toolbar> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 

    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end|bottom" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@android:drawable/ic_dialog_email" /> 

</android.support.design.widget.CoordinatorLayout> 

这里是我当前选项卡的xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin"> 
    <!--tools:context="com.example.martin.fitnessapp.MainActivity$PlaceholderFragment">--> 

    <ListView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/listViewMuscleGroups" 
     android:layout_alignParentStart="true" /> 

</RelativeLayout> 

对于每个片段,我都创建了扩展Fragment类的分隔类。如果你需要,我也可以添加这个类,但我认为这并不重要。

+0

不要删除这篇文章,这看起来像一个错误,这不应该认为发生 –

回答

0

android:layout_alignParentStart="true"(如果你使用RTL语言,则取决于右边),你可能还需要该ListView中的alignParentTop。列表视图可能也需要match_parent宽度。

无论如何,我不知道发生了什么,但是我会将app:layout_behavior="@string/appbar_scrolling_view_behavior"移动到包含ListView的RelativeLayout,因为这会导致ViewPager的片段内容像这样被绘制。

为了记录,我没有太多的协调员布局经验。

+0

感谢您的响应...我用whis命令找到解决方案:android:layout_marginBottom =“?android:attr/actionBarSize” – Aligator

+0

是的,好吧,我想说,另一种选择是在底部添加保证金(在iOS上添加“insets”),这基本上是Android上的填充:) –