2016-10-08 1 views
1

Je construis une page avec une Linearlayout et de nombreux éléments à l'intérieur. Au bas de l'écran, je veux ajouter une ligne, en séparant le «pied de page». Comment cela peut il etre accompli? Je pensais à quelque chose en tant que TextView, et la ligne à ajouter au texte, mais je suis sûr qu'il y a une meilleure façon de faire. Merci!Comment séparer le pied de page d'une mise en page avec une ligne en android

+0

poster votre fichier XML, afin que les gens peuvent vous aider – sushildlh

+0

Eh bien, je me demande ce qu'il faut publier exactement, pas de problème autrement. Ce n'est pas dans un xml, je n'ai que la disposition. Ou probablement je dois ajouter un xml et spécifier le devider là? – user6456773

+0

utilisation ci-dessous répondre vous avez une idée – sushildlh

Répondre

2

juste ajouter une vue avec spécifier fond dans la mise en page XML comme ci-dessous:

<View 
    android:layout_width="match_parent" 
    android:layout_height="0.5dp" 
    android:background="@android:color/darker_gray"/> 
+0

Merci beaucoup! Cela fonctionne très bien! – user6456773

2

utilisent ce xml pour votre but ...... Il vient par exemple ....

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="5"> 

     <TextView 
      android:id="@+id/text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Hello World!" /> 

    </LinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="#000"/> 

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

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:text="Footer" /> 

    </LinearLayout> 


</LinearLayout> 

Note: - 2e mise en page est linéaire Pour le contenu principal .... 3ème mise en page linéaire pour le pied de page .....

sortie xml ci-dessus ..

h

+0

Merci, cela a fonctionné avec l'ajout de la vue, j'ai oublié de son existence :))) – user6456773

+0

vous êtes les bienvenus ........ – sushildlh

1

Pour SEPERATE Footer du Contai Vous pouvez ajouter line en tant que Seperator. Mais je peux donner une meilleure approche, vous devez ajouter Shadow au LinearLayout il sera logique que votre conteneur principal et le pied de page seront séparés.

Mon approche.

footer.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="60dp" 
    android:background="@drawable/linearlayout_upper_shadow" 
    android:layout_alignParentBottom="true"> 
    <LinearLayout 
     android:id="@+id/below_linear_layout" 
     android:layout_width="0.0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="50.0" 
     android:orientation="vertical" 
     android:weightSum="1"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="0.0dp" 
      android:layout_marginLeft="@dimen/normal_margin15" 
      android:layout_marginTop="@dimen/normal_margin5" 
      android:layout_weight="0.50" 
      android:text="$1,605" 
      android:textSize="@dimen/textsize20" 
      android:textColor="@color/black1" /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="0.0dp" 
      android:layout_marginLeft="@dimen/normal_margin15" 
      android:layout_weight="0.50" 
      android:text="View price detail" 
      android:textColor="@color/colorPrimary" 
      android:textSize="@dimen/textsize13" 
      android:layout_marginTop="-5dp" /> 
    </LinearLayout> 
    <Button 
     android:id="@+id/continue_button" 
     android:layout_width="0.0dip" 
     android:layout_height="match_parent" 
     android:layout_margin="@dimen/normal_margin8" 
     android:layout_weight="50.0" 
     android:background="@color/colorPrimary" 
     android:gravity="center" 
     android:text="@string/continue_string" 
     android:textColor="@color/white1" 
     android:textSize="@dimen/textsize13" /> 
</LinearLayout> 

pour séparateur.

separator.xml

<?xml version="1.0" encoding="utf-8" ?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
    <shape android:shape="rectangle"> 
     <solid android:color="@color/linear_layout_shadow"/> 
     /> 
    </shape> 
    </item> 

    <item 
     android:left="0dp" 
     android:right="0dp" 
     android:top="1dp" 
     android:bottom="0dp"> 
    <shape android:shape="rectangle"> 
     <solid android:color="@android:color/white"/> 
     <corners android:radius="2dp" /> 
    </shape> 
    </item> 
</layer-list> 

OutPut:

enter image description here