0

Ich habe dieses Layout:Linearlayout nicht statt über Fragment unter

<?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> 

und wenn ich ein Listview in meinem fragment_container haben, der Spieler mit Play/Pause/Vor/Rücklauf-Taste alway über das ist container, so dass ich nicht auf das letzte Element in der Listenansicht zugreifen kann, da es sich hinter meinem Player befindet (das lineare Layout nach dem fragment_container).

Was sollte ich für den Container ändern nur den Platz nehmen, den er hat und nicht unter meinem Player gehen?

Übrigens ist dieses Layout im Layout meiner Hauptaktivität enthalten, das ist ein DrawerLayout, das meinen Container + eine NavigationView enthält.

+0

betrachten, um es mit LinearLayout oder RelativeLayout zu verformen, damit es funktioniert. Erstelle Linearlayout und lege dein Appbarlayout und Frame-Layout hinein. – ZeroOne

Antwort

0

Fügen Sie dem Container eine android:layout_marginBottom-Eigenschaft hinzu, die der Höhe des Players entspricht.

+0

Das ist, was ich schließlich getan habe, aber der Player kann eine andere Größe haben, abhängig vom Namen des Songs (ein langer Titel wird 2 Zeilen verwenden) – Maloz

+0

So versuchen Sie, die Höhe des Players programmgesteuert zu erhalten, und ändern Sie die unteren Margin's Eigenschaft des Containers. Oder Sie könnten für den Player das erweiterbare BottomSheetBehavior von Design Support LIbrary verwenden. – GPack

+0

Danke, wirf einen Blick auf BottomSheetBehavior, klingt gut für das, was ich will! – Maloz

Verwandte Themen