2016-07-05 9 views
0

enter image description here Ich habe ein Problem mit meinem Layout. Text mit dieser ID "@ + id/ConnectInfo" "springt" aus "@ drawable/top_panel" heraus. Ich kann nicht verstehen, warum es so ist. Kann mir jemand helfen, meinen Text im Zielbereich zu korrigieren?Android Layout TextView springt von LinearLayout

Das ist mein voller Layout:

<FrameLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:accessibilityLiveRegion="assertive"> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <com.test.myapplication.CustomLogoView 
     android:id="@+id/custom_logo_view1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 

    /> 
</RelativeLayout> 

<!-- 
Слой приложения  
--> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 

     android:paddingBottom="0dp" 
     android:paddingLeft="0dp" 
     android:paddingRight="0dp"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:background="@drawable/top_panel" 
      android:orientation="horizontal" 
      android:paddingBottom="0dp" 
      android:paddingLeft="0dp" 
      android:paddingRight="0dp"> 

      <TextView 
       android:id="@+id/connectInfo" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Medium Text" 
       android:textAppearance="?android:attr/textAppearanceMedium"/> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="4" 
      android:orientation="horizontal" 
      android:paddingBottom="0dp" 
      android:paddingLeft="0dp" 
      android:paddingRight="0dp"> 


      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1" 
       android:orientation="vertical" 
       android:paddingBottom="0dp" 
       android:paddingLeft="0dp" 
       android:paddingRight="0dp"> 


       <ImageButton 
        android:id="@+id/btnStart" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_gravity="bottom" 
        android:layout_weight="1" 
        android:background="#00000000" 
        android:scaleType="fitStart" 
        android:src="@drawable/btn_sqr_search_land"/> 


       <ImageButton 
        android:id="@+id/btnOldDev" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_gravity="bottom" 
        android:layout_weight="1" 
        android:background="#00000000" 
        android:scaleType="fitStart" 
        android:src="@drawable/btn_sqr_list_land"/> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="5" 
       android:orientation="vertical" 
       android:paddingBottom="0dp" 
       android:paddingLeft="0dp" 
       android:paddingRight="0dp"> 

       <RelativeLayout 
        android:id="@+id/relativeLayout" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:paddingBottom="16dp" 
        android:paddingLeft="0dp" 
        android:paddingRight="22dp" 
        android:paddingTop="16dp"> 
        <ListView 
         android:id="@+id/listView1" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:divider="@null" 
         android:dividerHeight="0dp"> 
        </ListView> 

       </RelativeLayout> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 
</RelativeLayout> 

+2

Können Sie Screenshot des Problems vorschlagen? –

+0

Entfernen Sie alle überflüssigen Leerzeilen aus Ihrem Layout-XML. –

+0

Ok! Kein Problem. –

Antwort

0

Ändern Sie diese Zeile android:layout_height="0dp" zu android:layout_height="wrap_content"

. 
. 
. 
<LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" //change this line 
     android:layout_weight="1" 
     android:paddingLeft="0dp" 
     android:paddingRight="0dp" 
     android:paddingBottom="0dp" 
     android:background="@drawable/top_panel"> 


     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Medium Text" 
      android:id="@+id/connectInfo" 

      /> 



</LinearLayout> 
. 
. 
. 
+0

Ja, aber es bricht "Layout-Gewicht-System" ... und dieses Layout wird sehr groß (( –

+0

) Sie haben nur ein Kind in diesem LinearLayout können Sie das Gewicht entfernen – ebyt

+0

Ich kann Layout entfernen und Text stattdessen einstellen. Aber ich habe vor, Exit-Taste an der Spitze zu haben ... Jetzt füge ich hinzu Text in relativelayout .. es funktioniert, aber es sieht hässlich aus ... wie ein Hack. –