2015-08-26 1 views
0

J'ai cette mise en page pour un fragment:Overlay un élément de vue

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 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" > 

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

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <include layout="@layout/header" /> 
    </FrameLayout> 

    <ListView 
     android:id="@+id/listview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="none" > 
    </ListView> 
</LinearLayout> 
</FrameLayout> 

ce qui est en-tête:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" > 

    <Button 
     android:id="@+id/button" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"/> 

    <LinearLayout 
    android:id="@+id/box" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:visibility="gone" /> 

</LinearLayout > 

maintenant lorsque le bouton est pressé, « boîte » doit être remplie et deviennent visibles , et la boîte superpose le reste des vues (dans mon cas listview). Maintenant, quand j'appuie sur le bouton, le boeuf ne superpose pas la liste, mais prend une partie de l'écran (et le listview descend). Comment puis-je faire? grâce

Répondre

0

Il suffit d'utiliser un RelativeLayout au lieu de LinearLayout, et mettre le FrameLayout après la ListView en xml (pour placer l'en-tête sur la liste):

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ListView 
     android:id="@+id/listview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="none" > 
    </ListView> 


    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" > 

     <include layout="@layout/header" /> 
    </FrameLayout> 

</RelativeLayout>