2017-02-19 3 views
0

Ich, m versuchen, die Schwerkraft-Center, aber funktioniert nicht. Hier ist mein XML. Was mache ich falsch?Schwerkraft arbeitet nicht im Layout

Ich angehängt Bild wie XML jetzt aussieht.

ich, habe ein Root-Layout, teilte ich es zwei Teil, und ich möchte jeden Teil Schwerpunkt

<LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dip" 
      android:layout_weight="2" 
      android:background="@color/bluefontcolor" 
      android:gravity="center_vertical" 
      android:orientation="horizontal" 
      android:weightSum="2"> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:gravity="center"> 

       <com.developer.lucky.modernbalda.Flipmeter 
        android:id="@+id/scoreboard_1" 
        android:layout_width="0dip" 
        android:layout_height="@dimen/_60sdp" 
        android:layout_gravity="center" 
        android:layout_margin="10dp" 
        android:layout_weight="1" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:gravity="center"> 

       <com.developer.lucky.modernbalda.Flipmeter 
        android:id="@+id/scoreboard_2" 
        android:layout_width="0dip" 
        android:layout_height="@dimen/_60sdp" 
        android:layout_gravity="center" 
        android:layout_margin="10dp" 
        android:layout_weight="1" /> 
      </LinearLayout> 


     </LinearLayout> 

enter image description here

Antwort

1

Vielleicht ist die Flipmeter Breite hat, ist das Problem, wie sie festgelegt sind Füllen Sie das übergeordnete Element LinearLayout, so dass sie so breit wie das übergeordnete Element gerendert werden (einschließlich des unsichtbaren Teils).

Versuchen Sie, setzen Sie ihre Breite auf wrap_content oder ändern Sie ihre layout_gravity zu gravity sollte das Problem lösen.

+0

i versuchte –

0

dies unter Attribut Versuchen

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:layout_weight="2" 
     android:background="@color/bluefontcolor" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" 
     android:weightSum="2"> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center"> 

      <com.developer.lucky.modernbalda.Flipmeter 
       android:id="@+id/scoreboard_1" 
       android:layout_width="wrap_content" 
       android:layout_height="@dimen/_60sdp" 
       android:layout_margin="10dp"/> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center"> 

      <com.developer.lucky.modernbalda.Flipmeter 
       android:id="@+id/scoreboard_2" 
       android:layout_width="wrap_content" 
       android:layout_height="@dimen/_60sdp" 
       android:layout_margin="10dp"/> 
     </LinearLayout> 
</LinearLayout> 
+0

nicht funktioniert ich versuchte –

+0

nicht funktioniert im Layout jedes Mitglieds Zentrum .... sollte das Element in wrap_content Abmessungen verwenden und die Schwerkraft zum Zentrum in Mutter gesetzt –

0

in beiden

Flipmeter hinzufügen unter Attribut
android:gravity="center" 

und auch von beiden Flipmeter entfernen führen, dass Sie Breite von Linearlayout eingestellt haben 0DP.

android:layout_gravity="center" 
Verwandte Themen