Mit TextView
innerhalb GridLayout
problematisch ist, aber es ist eine gute Möglichkeit, beide zusammen zu verwenden.
Dies ist, was das Beispiel Layout wie folgt aussieht:
Und das ist das komplette Layout xml, die wichtigen Linien sind mit *** markiert.
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3" * this example uses 3 columns
android:orientation="horizontal" > *** use "horizontal"
<TextView * just a normal view
android:layout_column="0"
android:layout_row="0"
android:background="#666666"
android:text="A"
android:textColor="#afafaf"
android:textSize="60sp"
android:textStyle="bold" />
<TextView * this text will not be cut!
android:layout_width="0dp" *** important: set width to 0dp
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_columnSpan="2" * colspan does also work with this
android:layout_gravity="fill_horizontal|bottom" *** set to "fill*"!
android:layout_row="0"
android:text="This view has 2 columns. Lorem ipsum dolor sit amet, consetetur sadipscing elitr."
android:textColor="#666666" />
</GridLayout>
Je nach Bedarf, auch wird diese Kombination arbeiten:
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="fill"
android:gravity="bottom"
Beachten Sie, dass Sie haben keinen Namensraum verwenden, um andere als android
für diese zu arbeiten.
Es ist wichtig, die ** app: ** layout_gravity zu beachten. Ich habe den Wert in einem Stil festgelegt, und er hat mich nicht gewarnt, hat mich eine Weile gebraucht, um das Problem herauszufinden. – basilisk
Es nimmt die Breite der vorherigen Zeile der Breite, wenn es in der zweiten Zeile befindet –