0

我有這樣的佈局:的LinearLayout沒有發生過片段

<?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:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="ca.usherbrooke.whapl.MainActivity"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    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="@color/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay" 
     app:elevation="4dp"/> 

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


<FrameLayout 
    android:id="@+id/fragment_container" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 
     android:orientation="horizontal" 
     android:paddingTop="5dp" 
     android:paddingBottom="10dp" 
     android:background="@color/colorPrimary" 
     > 

     <ImageView 
      android:id="@+id/previous" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:src="@drawable/ic_action_previous"/> 

     <ImageView 
      android:id="@+id/play_pause" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:src="@drawable/ic_action_play"/> 

     <ImageView 
      android:id="@+id/next" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:src="@drawable/ic_action_next"/> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="bottom" 
     android:orientation="horizontal" 
     android:paddingBottom="10dp" 
     android:background="@color/colorPrimary" 
     > 

     <TextView 
      android:layout_marginLeft="10dp" 
      android:id="@+id/songname" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textColor="@color/white" 
      /> 
    </LinearLayout> 

</LinearLayout> 

,當我在fragment_container有一個ListView,與遊戲玩家/暫停/下一個/快退按鈕常是在容器,所以我無法訪問列表視圖中的最後一個元素,因爲它位於我的播放器後面(fragment_container之後的線性佈局)。

我應該爲容器更換什麼樣的東西,取而代之的是他自己的位置,而不是在我的播放器下面?

順便說一句,這個佈局被包含在我的主要活動的佈局中,這是一個DrawerLayout,它包含我的容器+一個NavigationView。

+0

考慮使用LinearLayout或RelativeLayout使其變形。創建Linearlayout並將您的appbarlayout和framelayout放入其中。 – ZeroOne

回答

0

android:layout_marginBottom屬性添加到等於玩家身高的容器。

+0

這就是我終於做的,但玩家可以有不同的大小,這取決於歌曲的名稱(長標題將使用2行) – Maloz

+0

因此,嘗試以編程方式獲取播放器的高度,並根據更改調整bottomMargin集裝箱的財產。 或者您可以使用設計支持LIbrary中可展開的BottomSheetBehavior播放器。 – GPack

+0

謝謝,將看看BottomSheetBehavior,聽起來不錯,我想要的! – Maloz