Ein bisschen spät, aber vielleicht könnte jemand anderes das brauchen.
Sie können dies auch mit xml-Layouts tun. Da Sie ein "tabellenartiges" Format haben möchten, empfehle ich Ihnen, ein GridLayout für Ihre Zwecke zu verwenden.
Hier können Sie Ihre TextViews definieren und sie der gewünschten Zeile und Spalte zuweisen. Verwenden Sie die Parameter android:layout_column="..."
und android:layout_row="..."
, um dem TextView mitzuteilen, in welcher Spalte und Zeile er erscheinen soll.
Ab API11 können Sie das xml-Attribut android:rotation="..."
zum Drehen Ihres TextView verwenden. Das Attribut verwendet einen Gleitkommawert, der den Winkel zum Drehen von TextView darstellt.
Die, wenn Sie entwickeln für API14 und über Ihnen das android:layout_rowspan="..."
Attribut zum Erzeugen des rowspan im
Zum Beispiel ein wenig Code Grid
verwenden:
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- column 0 start -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:text="ABC" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="1"
android:layout_rowSpan="3"
android:rotation="-90.0"
android:layout_gravity="center_vertical"
android:text="2011" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_row="4"
android:text="DEF" />
<!-- column 0 end -->
<!-- column 1 start -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="0"
android:text="XXXXX" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="1"
android:text="XXXXX" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="2"
android:text="XXXXX" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="3"
android:text="XXXXX" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="4"
android:text="XXXXX" />
<!-- column 1 end -->
</GridLayout>
Dies ist eine kleine Screenshot, wie das Layout aussieht
Cool. Vielen Dank; aber ... wenn ich das TextView in einer TableRow-Zelle rotiere, muss ich auch eine Art ROWSPAN machen, weil das 2011 3 Reihen benutzen muss ... wie kann ich das tun? – Cris
Rowspan ist nicht möglich AFAIK. Sie müssen diese gedrehte Ansicht und die Ansichten daneben in einer RelativeLayout- oder anderen Ansichtsgruppe platzieren. Werfen Sie einen Blick auf diese Frage: http://stackoverflow.com/questions/2189986/android-table-layout-rowspan – Cristian
Vielen Dank, Ihr Link wird mir sicherlich helfen! – Cris