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上的填充:) –