Ich versuche, ein Taschenrechnerlayout mit TableLayout zu erstellen, aber die letzten zwei Zeilen sind nicht mit dem Rest des Layouts ausgerichtet. Stimmt etwas mit meinem Layout-XML nicht?Brauchen Sie Hilfe mit Android TableLayout Ausrichtung
Was ich versuche leichter zu tun, wäre in HTML (<td>
mit colspan
oder rowspan
) zu erreichen, so soll ich dies in ein WebView versuchen konvertieren?
-Code ist wie folgt: (Screenshot)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TableLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:stretchColumns="*">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<Button
android:id="@+id/Button08"
android:textSize="16pt"
android:text="^"
android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="wrap_content" />
<Button
android:id="@+id/Button09"
android:text="÷"
android:textSize="16pt"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_width="wrap_content" />
<Button
android:id="@+id/Button10"
android:text="×"
android:textSize="16pt"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_width="wrap_content" />
<Button
android:id="@+id/Button11"
android:textSize="16pt"
android:text="-"
android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="wrap_content" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1">
<Button
android:id="@+id/Button01"
android:text="7"
android:textSize="16pt"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<Button
android:layout_height="wrap_content"
android:textSize="16pt"
android:text="4"
android:id="@+id/Button05"
android:layout_weight="1"
android:layout_width="fill_parent" />
</LinearLayout>
<LinearLayout
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="fill_parent">
<Button
android:id="@+id/Button02"
android:layout_height="wrap_content"
android:text="8"
android:textSize="16pt"
android:layout_weight="1"
android:layout_width="fill_parent" />
<Button
android:layout_height="wrap_content"
android:textSize="16pt"
android:text="5"
android:id="@+id/Button06"
android:layout_weight="1"
android:layout_width="fill_parent" />
</LinearLayout>
<LinearLayout
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="fill_parent">
<Button
android:id="@+id/Button03"
android:text="9"
android:textSize="16pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:textSize="16pt"
android:text="6"
android:id="@+id/Button07"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<Button
android:id="@+id/Button04"
android:text="+"
android:textSize="16pt"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="2">
<LinearLayout
android:layout_weight="1"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/Button02"
android:textSize="16pt"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="1" />
<Button
android:textSize="16pt"
android:id="@+id/Button06"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="2" />
</LinearLayout>
<Button
android:id="@+id/Button01"
android:layout_height="wrap_content"
android:textSize="16pt"
android:layout_weight="1"
android:layout_width="fill_parent"
android:text="0" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1">
<Button
android:id="@+id/Button03"
android:textSize="16pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3" />
<Button
android:textSize="16pt"
android:id="@+id/Button07"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="." />
</LinearLayout>
<Button
android:id="@+id/Button04"
android:textSize="16pt"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="1"
android:text="=" />
</TableRow>
</TableLayout>
</LinearLayout>
Offensichtlich nimmt '=' Knopf mehr Raum als, was Sie beabsichtigten. Versuchen Sie, den Parameter layout_weight der Schaltfläche "=" anzupassen. – primpap
"aber die letzten beiden Zeilen stimmen nicht mit dem Rest des Layouts überein" - Ich kann Ihren Bildschirm von hier aus nicht sehen. Kannst du einen Screenshot von dem, was du siehst, posten? Wenn Sie ein Modell haben, das zeigt, was Sie erreichen möchten, um so besser. – CommonsWare
primalpop, änderte ich sein Gewicht auf 0 und jetzt habe ich http://img683.imageshack.us/img683/2043/calculatororroidlayout.png. Gibt es eine Möglichkeit, dass eine Tabellenzelle mehrere Zeilen/Spalten umfassen kann, ohne verschachtelte LinearLayouts zu verwenden? CommonsWare, http://img185.imageshack.us/img185/2043/calculatororroidlayout.png war das Original und http://img683.imageshack.us/img683/2043/calculatorandroidlayout.png ist die aktuelle Version. –