2017-03-30 3 views
0

Ich versuche ein relatives Layout für mein Schulprojekt zu erstellen. Das mittlere Element verweigert die gleiche Höhe und Entfernung von oben wie die anderen. Wie behebe ich das?Warum sieht mein relatives Format peinlich aus?

Bearbeiten: Um die Symbole zu verdeutlichen sind TextViews mit fontAwesome. Debugging ein wenig Ich wechselte die Symbole der linken und mittleren Container und das Zentrum war immer noch höher, ich glaube, es ist ein Problem der Formatierung.

Layout:

<RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingTop="10dp" 
     android:orientation="horizontal"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:orientation="vertical" 
      android:paddingTop="10dp"> 

      <TextView 
       android:id="@+id/icDate" 
       android:textAppearance="@color/colorPrimaryDark" 
       android:text="@string/fa_calender" 
       android:textSize="24sp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:textAlignment="center"> 
      </TextView> 

      <TextView 
       android:textAppearance="@color/colorPrimaryDark" 
       android:id="@+id/tvDate" 
       android:textSize="14sp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:textAlignment="center"> 
      </TextView> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:orientation="vertical" 
      android:paddingTop="10dp"> 

      <TextView 
       android:id="@+id/icDuration" 
       android:textAppearance="@color/colorPrimaryDark" 
       android:text="@string/fa_time" 
       android:textSize="24sp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:textAlignment="center"> 
      </TextView> 

      <TextView 
       android:textAppearance="@color/colorPrimaryDark" 
       android:id="@+id/tvDuration" 
       android:textSize="14sp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:textAlignment="center"> 
      </TextView> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:orientation="vertical" 
      android:paddingTop="10dp"> 

      <TextView 
       android:id="@+id/icDistance" 
       android:textAppearance="@color/colorPrimaryDark" 
       android:text="@string/fa_road" 
       android:textSize="24sp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:textAlignment="center"> 
      </TextView> 

      <TextView 
       android:textAppearance="@color/colorPrimaryDark" 
       android:id="@+id/tvDistance" 
       android:textSize="14sp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:textAlignment="center"> 
      </TextView> 

     </LinearLayout> 


    </RelativeLayout> 

mit bg Problem markieren:

enter image description here

ohne bg

enter image description here

+0

Vielleicht ist die Größe des Bildes anders? –

Antwort

0

Zwei Wege, dies zu tun.

1, Verwenden Sie Paint, um sicherzustellen, dass Ihre Bildgröße völlig gleich ist.

2, passen Sie die Bildgröße in bestimmten

  android:layout_width="30dp" 
      android:layout_height="30dp" 
+0

leider sind sie einfach Symbole aus einer Schriftart. –

+0

Verwenden Sie nicht fontAwesome machen das Ding einfach. Natürlich wenn es für den Einsatz bestimmt ist. – nikeru8

0

Haben Sie versucht, mit android:layout_centerVertical="true" in allen Ihren LinearLayout?

Denken Sie daran, dass Sie das Symbol Zentrum muss plus das Datum oder Text was auch immer unter dem Symbol ist. Daher müssen Sie den Container von beiden zentrieren, der LinearLayout ist.

Außerdem zentriert der android:textAlignment="center" den Text in seinen eigenen Grenzen. Es zentriert es nicht in seinem übergeordneten Layout.

Verwandte Themen