2013-03-12 14 views
9

Bir RelativeLayout bir LinearLayout ortalamak istiyorum ama bir sorun var, margin-bottom dibe bağlı kalır. İşte görünümüdür:Nasıl RelativeLayout bir LinearLayout ortalamak için?

http://nsa33.casimages.com/img/2013/03/12//130312103139937791.png

Ve burada düzen kodunuz: bloğunu ortalamak için bazı fikirler varsa

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/group_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white" 
     android:orientation="vertical" > 

     <RelativeLayout 
      android:id="@+id/carreGlobalInterieur" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="5dp" 
      android:background="@color/grisTresClair" > 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="@drawable/border_deals" 
       android:orientation="vertical" > 

        <RelativeLayout 
         android:id="@+id/GroupLigneOne" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="8dp" > 

         <LinearLayout 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:background="@color/grisClair" 
          android:orientation="vertical" > 

          <TextView 
           android:id="@+id/CategorieDeal" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_marginLeft="5dp" 
           android:layout_marginRight="5dp" 
           android:text="My Category" 
           android:textColor="@color/white" /> 

         </LinearLayout> 

         <LinearLayout 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_alignParentRight="true" > 

          <TextView 
           android:id="@+id/nouveauPrixVert" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="10.99 €" 
           android:textColor="@color/green" 
           android:textStyle="bold" /> 

          <TextView 
           android:id="@+id/ancienPrixRouge" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_marginLeft="7dp" 
           android:layout_marginRight="6dp" 

           android:text="20.90 €" 
           android:textAppearance="?android:attr/textAppearanceMedium" 
           android:textColor="@color/red" 
           android:textSize="13sp" 
           android:textStyle="bold" /> 

          <TextView 
           android:id="@+id/reductionPrix" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:layout_marginRight="4dp" 

           android:text="(-34%)" 
           android:textColor="@color/red" 
           android:textStyle="bold" /> 

         </LinearLayout> 

        </RelativeLayout> 

       <LinearLayout 
        android:id="@+id/ligneTwo" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginLeft="3dp" 
        android:orientation="vertical" > 

        <TextView 
         android:id="@+id/titreEnGros" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:layout_gravity="center" 
         android:layout_marginTop="3dp" 
         android:text="Here is an example of a compleete title in a TextView Android" 
         android:textAppearance="?android:attr/textAppearanceMedium" 
         android:textColor="@color/black" 
         android:textSize="16sp" /> 

       </LinearLayout> 

       <RelativeLayout 
        android:id="@+id/ligneFour" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="3dp" 
        android:orientation="vertical" > 

        <TextView 
         android:id="@+id/dateAjout" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="5dp" 

         android:text="il y a 2 heures" /> 

        <TextView 
         android:id="@+id/siteWeb" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentRight="true" 
         android:layout_marginRight="5dp" 

         android:text="Amazon" /> 

       </RelativeLayout> 

      </LinearLayout> 

     </RelativeLayout> 

</RelativeLayout> 

, bana yardım edin!

cevap

26

RelativeLayout'u kullanırken, ne yazdığını söyleyen android:layout_centerInParent="true" numaralı telefonu kullanabilirsiniz.

+3

Evet !! İşe yarıyor ! Teşekkürler ! –