2017-11-30 12 views
2

Ich möchte einen Text über der Titelleiste platzieren. Aber das Problem ist, dass ich den "Registry-Text" nicht mit der entsprechenden Titelleiste ausrichten konnte, obwohl ich das Gewicht platziert habe.Wie platziere ich das Splitting-Layout unter der Tabellenüberschrift?

Hier ist der Code, was ich versuchte.

 <?xml version="1.0" encoding="utf-8"?> 
    <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/colorWhite" 
     android:isScrollContainer="false"> 

//this layout is not aligning properly with corresponding titles. 

      <LinearLayout 
       android:id="@+id/rel0" 
       android:layout_width="match_parent" 
       android:layout_height="33dp" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_marginTop="14dp" 
       android:gravity="center_vertical" 
       android:weightSum="10"> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_alignParentLeft="true" 
        android:layout_weight="2.5" 
        android:gravity="center" 
        android:text="14.30WIB" 
        android:textColor="@color/colorBlack" 
        android:textSize="14sp" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.5" 
        android:gravity="center" 
        android:text="Sell in" 
        android:textColor="@color/colorBlack" 
        android:textSize="10sp" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.2" 
        android:gravity="center" 
        android:text="Sell in" 
        android:textColor="@color/colorBlack" 
        android:textSize="10sp" /> 

       <LinearLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:orientation="vertical"> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="Registrasi" 
         android:textColor="@color/colorBlack" 
         android:textSize="10sp" /> 

        <LinearLayout 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:orientation="horizontal"> 

         <TextView 
          android:layout_width="0dp" 
          android:layout_height="match_parent" 
          android:layout_weight="1.2" 
          android:gravity="center" 
          android:text="New" 
          android:textColor="@color/colorBlack" 
          android:textSize="10sp" /> 

         <TextView 
          android:layout_width="0dp" 
          android:layout_height="match_parent" 
          android:layout_weight="1.2" 
          android:gravity="center" 
          android:text="Re" 
          android:textColor="@color/colorBlack" 
          android:textSize="10sp" /> 
        </LinearLayout> 
       </LinearLayout> 


       <TextView 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.2" 
        android:gravity="center" 
        android:text="Edukasi" 
        android:textColor="@color/colorBlack" 
        android:textSize="8sp" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.2" 
        android:gravity="center" 
        android:text="POSM" 
        android:textColor="@color/colorBlack" 
        android:textSize="8sp" /> 

      </LinearLayout> 

     <LinearLayout 
       android:id="@+id/rel1" 
       android:layout_width="match_parent" 
       android:layout_height="33dp" 
       android:layout_below="@+id/rel0" 
       android:layout_marginLeft="10dp" 
       android:layout_marginRight="10dp" 
       android:background="@drawable/nbd_title" 
       android:gravity="center_vertical" 
       android:weightSum="10"> 

       <TextView 
        android:id="@+id/siteId" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_alignParentLeft="true" 
        android:layout_weight="2.5" 
        android:gravity="center" 
        android:text="Total" 
        android:textColor="@color/colorWhite" 
        android:textSize="12sp" /> 

       <TextView 
        android:id="@+id/site" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.5" 
        android:gravity="center" 
        android:text="XXXXX" 
        android:textColor="@color/colorWhite" 
        android:textSize="12sp" /> 

       <TextView 
        android:id="@+id/twoG" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.2" 
        android:gravity="center" 
        android:text="XXX" 
        android:textColor="@color/colorWhite" 
        android:textSize="12sp" /> 

       <TextView 
        android:id="@+id/threeG" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.2" 
        android:gravity="center" 
        android:text="XXX" 
        android:textColor="@color/colorWhite" 
        android:textSize="12sp" /> 

       <TextView 
        android:id="@+id/fourG" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.2" 
        android:gravity="center" 
        android:text="XXX" 
        android:textColor="@color/colorWhite" 
        android:textSize="12sp" /> 

       <TextView 
        android:id="@+id/retailerId" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.2" 
        android:gravity="center" 
        android:text="XXX" 
        android:textColor="@color/colorWhite" 
        android:textSize="12sp" /> 

       <TextView 
        android:id="@+id/idealId" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.2" 
        android:gravity="center" 
        android:text="XXX" 
        android:textColor="@color/colorWhite" 
        android:textSize="12sp" /> 

      </LinearLayout> 
      </LinearLayout> 
</android.support.v4.widget.NestedScrollView> 

Meine Ausgabe sieht so aus, die nicht richtig mit entsprechenden Titeln ausgerichtet ist.

enter image description here

tatsächliche Ausgang: (Sie können sehen, wo registrasi Text in zwei über dem correspodning titlebar spaltet Aber ich konnte das nicht verwendet werden.)

enter image description here

mich bitte korrigieren, wo ich bin Fehler machen.

+0

Warum Sie nicht verwenden Tablelayout und TableRows? – dalla92

+0

Ich möchte nicht TableLayout und Tabellenzeilen verwenden. Ohne Verwendung von Tabellenlayout und Zeilen nicht möglich? – Walter

+0

Sehen Sie meinen Beitrag es wird Ihnen helfen ... Ich habe Ihr Layout Problem behoben – Raja

Antwort

1

Sie haben Gewichte falsch verwendet. Es wurde hier behoben.

<android.support.v4.widget.NestedScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:isScrollContainer="false"> 

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

     <LinearLayout 
      android:id="@+id/rel0" 
      android:layout_width="match_parent" 
      android:layout_height="33dp" 
      android:gravity="center_vertical" 
      android:weightSum="10"> 

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_alignParentLeft="true" 
       android:layout_weight="2.5" 
       android:gravity="center" 
       android:text="14.30WIB" 
       android:textSize="14sp" /> 

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.5" 
       android:gravity="center" 
       android:text="Sell in" 
       android:textSize="10sp" /> 

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.2" 
       android:gravity="center" 
       android:text="Sell in" 
       android:textSize="10sp" /> 

      <LinearLayout 
       android:layout_width="0dp" 
       android:layout_weight="2.4" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center" 
        android:text="Registrasi" 
        android:textSize="10sp" /> 

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

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="match_parent" 
         android:layout_weight="1" 
         android:gravity="center" 
         android:text="New" 
         android:textSize="10sp" /> 

        <TextView 
         android:layout_width="0dp" 
         android:layout_height="match_parent" 
         android:layout_weight="1" 
         android:gravity="center" 
         android:text="Re" 
         android:textSize="10sp" /> 
       </LinearLayout> 
      </LinearLayout> 


      <TextView 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.2" 
       android:gravity="center" 
       android:text="Edukasi" 
       android:textSize="8sp" /> 

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.2" 
       android:gravity="center" 
       android:text="POSM" 
       android:textSize="8sp" /> 

     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/rel1" 
      android:layout_width="match_parent" 
      android:layout_height="33dp" 
      android:layout_below="@+id/rel0" 
      android:gravity="center_vertical" 
      android:weightSum="10"> 

      <TextView 
       android:id="@+id/siteId" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_alignParentLeft="true" 
       android:layout_weight="2.5" 
       android:gravity="center" 
       android:text="Total" 
       android:textSize="12sp" /> 

      <TextView 
       android:id="@+id/site" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.5" 
       android:gravity="center" 
       android:text="XXXXX" 
       android:textSize="12sp" /> 

      <TextView 
       android:id="@+id/twoG" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.2" 
       android:gravity="center" 
       android:text="XXX" 
       android:textSize="12sp" /> 

      <TextView 
       android:id="@+id/threeG" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.2" 
       android:gravity="center" 
       android:text="XXX" 
       android:textSize="12sp" /> 

      <TextView 
       android:id="@+id/fourG" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.2" 
       android:gravity="center" 
       android:text="XXX" 
       android:textSize="12sp" /> 

      <TextView 
       android:id="@+id/retailerId" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.2" 
       android:gravity="center" 
       android:text="XXX" 
       android:textSize="12sp" /> 

      <TextView 
       android:id="@+id/idealId" 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="1.2" 
       android:gravity="center" 
       android:text="XXX" 
       android:textSize="12sp" /> 

     </LinearLayout> 
    </LinearLayout> 
</android.support.v4.widget.NestedScrollView> 
1

Sie haben Ihr mit diesem Code unten zu ersetzen ... funktioniert gut .. Es wird Ihnen helfen ..

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/colorWhite" 
    android:isScrollContainer="false"> 

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

    <LinearLayout 
     android:id="@+id/rel0" 
     android:layout_width="match_parent" 
     android:layout_height="33dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="14dp" 
     android:gravity="center_vertical" 
     android:weightSum="10"> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_weight="2.5" 
      android:gravity="center" 
      android:text="14.30WIB" 
      android:textColor="@color/colorBlack" 
      android:textSize="14sp" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.5" 
      android:gravity="center" 
      android:text="Sell in" 
      android:textColor="@color/colorBlack" 
      android:textSize="10sp" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.2" 
      android:gravity="center" 
      android:text="Sell in" 
      android:textColor="@color/colorBlack" 
      android:textSize="10sp" /> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:layout_weight="2.4"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Registrasi" 
       android:gravity="center" 
       android:textColor="@color/colorBlack" 
       android:textSize="10sp" /> 

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

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        android:gravity="center" 
        android:text="New" 
        android:textColor="@color/colorBlack" 
        android:textSize="10sp" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        android:gravity="center" 
        android:text="Re" 
        android:textColor="@color/colorBlack" 
        android:textSize="10sp" /> 
      </LinearLayout> 
     </LinearLayout> 


     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.2" 
      android:gravity="center" 
      android:text="Edukasi" 
      android:textColor="@color/colorBlack" 
      android:textSize="8sp" /> 

     <TextView 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.2" 
      android:gravity="center" 
      android:text="POSM" 
      android:textColor="@color/colorBlack" 
      android:textSize="8sp" /> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/rel1" 
     android:layout_width="match_parent" 
     android:layout_height="33dp" 
     android:layout_below="@+id/rel0" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:background="#478387" 
     android:gravity="center_vertical" 
     android:weightSum="10"> 

     <TextView 
      android:id="@+id/siteId" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_weight="2.5" 
      android:gravity="center" 
      android:text="Total" 
      android:textColor="@color/colorWhite" 
      android:textSize="12sp" /> 

     <TextView 
      android:id="@+id/site" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.5" 
      android:gravity="center" 
      android:text="XXXXX" 
      android:textColor="@color/colorWhite" 
      android:textSize="12sp" /> 

     <TextView 
      android:id="@+id/twoG" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.2" 
      android:gravity="center" 
      android:text="XXX" 
      android:textColor="@color/colorWhite" 
      android:textSize="12sp" /> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="2.4" 
      android:orientation="horizontal" 
      android:weightSum="2"> 

     <TextView 
      android:id="@+id/threeG" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="XXX" 
      android:textColor="@color/colorWhite" 
      android:textSize="12sp" /> 

     <TextView 
      android:id="@+id/fourG" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:gravity="center" 
      android:text="XXX" 
      android:textColor="@color/colorWhite" 
      android:textSize="12sp" /> 

     </LinearLayout> 

     <TextView 
      android:id="@+id/retailerId" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.2" 
      android:gravity="center" 
      android:text="XXX" 
      android:textColor="@color/colorWhite" 
      android:textSize="12sp" /> 

     <TextView 
      android:id="@+id/idealId" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1.2" 
      android:gravity="center" 
      android:text="XXX" 
      android:textColor="@color/colorWhite" 
      android:textSize="12sp" /> 

    </LinearLayout> 

    </LinearLayout> 

    </android.support.v4.widget.NestedScrollView> 
Verwandte Themen