Ausrichtung von Columns in TableLayout

  • 0 Antworten
  • Letztes Antwortdatum
F

Flixius

Fortgeschrittenes Mitglied
4
Hi,

ich habe jetzt schon einige Zeit in das Problem gesteckt, aber ich komme einfach nicht weiter.

Meine App sieht derzeit wie folgt aus: Zippyshare.com - c.png (die warndreiecke sind im editor nur deswegen anezeigt, weil ich nicht @strings nutze, sondern direkt text in die textviews schreibe).

Alles wa sich erreichen möchte ist, dass direkt hinter den Values von Attr1,3 und 5 die Columns Attr2,4 und 6 anfangen und es nich zu so einer großen verschiebung kommt. Ich dachte wrap_content wäre die richtige Lösung, aber es will leider nicht so recht klappen. Welche Role layout_weight da spielt kann ich nicht so richtig überblicken. Ich habe den Code aus Beispielen zusammenkopiert und mich nach und nach etwas reingefuchst. Aber sowas wie ein Colspan scheint es wohl nicht zu geben.

Hier der komrpimierte Code meines XML:


Code:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TableLayout
        android:id="@+id/tablelayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="15dip"
        android:paddingRight="15dip"
        android:layout_marginTop="30dp"
        android:layout_marginBottom="30dp"
        android:stretchColumns="*" >
<!-- Einzeilige Row-->
        <TableRow style="@style/ColumnOrientationStyle" android:background="@drawable/cell_shape_odd">
            <TextView
                android:id="@+id/column0"
                android:text="Name"
                android:textAppearance="@android:style/TextAppearance.Medium" />
         </TableRow>

<!-- 4 columns in einer row-->
  <TableRow
            style="@style/ColumnOrientationStyle"
            android:background="@drawable/cell_shape_even" >
            <TextView
                android:id="@+id/attr1"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:text="Attr1" />
            <TextView
                android:id="@+id/Attr1Value"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:text="52" />
            <TextView
                android:id="@+id/attr2"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:text="Attr2" />
            <TextView
                android:id="@+id/Attr2Value"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:text="41" />
        </TableRow>

ColumnOrientationStyle: 
   <style name="ColumnOrientationStyle">
        <item name="android:paddingBottom">2dip</item>
        <item name="android:paddingTop">2dip</item>
        <item name="android:paddingLeft">5dip</item>
        <item name="android:paddingRight">5dip</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:orientation">horizontal</item>
    </style> 

cell_shape_odd und _even kümmern sich lediglich um die border und die hintergrundfarben.
Vielen Dank im voraus!
 
Zurück
Oben Unten