2010-10-03 7 views
0

J'essaie de créer une disposition empilée avec un en-tête fixe, un corps extensible et un pied de page fixe. Je suis très proche mais la section du corps avec la vue web s'affiche derrière le pied de page plutôt qu'entre l'en-tête et le pied de page. TIAAide pour la disposition empilée

Jim

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/header" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout 
    android:id="@+id/header" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/icon" /> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Karen" /> 

</LinearLayout> 

<RelativeLayout 
    android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_below="@id/header" 
     > 


<WebView 
    android:id="@+id/webview" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#000000" 
    /> 

<LinearLayout 
android:id="@+id/footer" 
android:layout_width='fill_parent' 
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true" 
android:orientation="horizontal" 
android:background="#000000" 
> 

<EditText 
android:id="@+id/inputText" 
android:layout_width="wrap_content" 
android:layout_height="fill_parent" 
    android:text="Is on the bottom" 
    android:layout_weight="1" 
    android:textSize="15sp" 
    /> 

<Button 
    android:layout_width="wrap_content" 
android:layout_height="fill_parent" 
    android:textSize="15sp" 
android:text="send" /> 

</LinearLayout> 


</RelativeLayout> 

</LinearLayout> 

Répondre

1

Je suis en train de faire une mise en page empilés avec un en-tête fixe, le corps extensible et pied de page fixe

Étape # 1: Faire la mise en page de la racine d'un RelativeLayout.

Étape # 2: Ajouter l'en-tête comme un enfant du RelativeLayout, ancré au sommet (android:layout_alignParentTop="true")

Étape 3: Ajoutez le pied de page comme un enfant du RelativeLayout, ancré au fond (android:layout_alignParentBottom="true")

Étape 4: Ajoutez le corps comme un enfant du RelativeLayout, ancré à l'en-tête (android:layout_below="...") et pied de page (un ndroid:layout_above="...")

0

SOLVED.

J'ai dû réorganiser les éléments dans le fichier .xml en plaçant l'élément central (webview) en bas et ajouter android: layout_above = "@ id/footer".

J'ai appris que lorsque android traite des id, ils doivent être définis avant d'utiliser les directives android: layout_above = "@ id/footer".

Cela ressemble beaucoup au traitement javascript au chargement de la page, les fonctions doivent être définies avant l'exécution.

BTW grâce à tout le monde chez StackOverFlow, vous en faites une ressource inestimable pour les développeurs.

Questions connexes