Ich habe Probleme mit dem Layout eines linearen Layout mit Elementen, die nebeneinander sind. Ich kann sie innerhalb eines linearen Layouts Seite an Seite gehen lassen, indem ich die Elemente in eine TableView setze, aber ich kann nicht die richtige Ausrichtung auf sie anwenden. z.B. die TextView1 ausrichten müssen links und sein Partner TextView2 ist richtig Auch die Taste ausrichten wird nicht ausrichten Rechts, auch wenn ichWie Layout Elemente nebeneinander auf einem linearen Layout und Anwendung richtigen Abstand und Ausrichtung
android:layout_alignParentRight="true"
verwenden Ich versuche, eine Quittung Tätigkeit, wo der Titel „SubTotal“, „Steuer“ zu schaffen, „Total“ ausgerichtet sind, nach links und ihre Werte ausgerichtet ist auf der rechten Seite Unten ist mein xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="20dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:showIn="@layout/app_bar_main"
tools:context=".MainActivity"
android:elevation=".5dp"
android:focusable="true"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:orientation="vertical"
android:gravity="bottom">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="SAN AGUSTIN MUSEUM"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textViewTicketName"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="(Comes with Audio Guide)"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textViewTicketDesc"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:orientation="vertical"
android:gravity="bottom">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/TblText1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="Subtotal:"/>
<TextView
android:id="@+id/TblText11"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="$5.00"
android:layout_alignParentRight="true"/>
</TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Subtotal $5.00"
android:paddingLeft="0dp"
android:layout_below="@+id/textViewTicketName"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textSubtotal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Tax $0.50"
android:paddingLeft="0dp"
android:layout_below="@+id/textViewTicketName"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textTax"/>
<View android:background="#000" android:layout_width="match_parent" android:layout_height="1px"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Total $5.50"
android:paddingLeft="0dp"
android:layout_below="@+id/textTotal"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textViewTotalAmount"/>
</LinearLayout>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" PURCHASE "
android:id="@+id/hiaButton"
android:onClick="hiaGetTicket"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:textSize="18sp"
android:textColor="@color/colorWhite"
android:alpha="20"
android:background="@drawable/buttonround"/>
</LinearLayout>
</ScrollView>
Dies ist, was ich bin auf dem Ziel. In der XML gibt es 2 Zwischensummenfelder, weil ich die TablView ausprobiert habe. Es muss nebeneinander sein, aber die Beschriftung auf der rechten Seite ist gerechtfertigt, rechts, während die Werte auf der rechten Seite rechts auch
gerechtfertigt istBisher in diesem was geschieht die XML unter mit
Haben Sie eine Rasteransicht versucht? –
Das Hinzufügen eines Bildes/einer Vorlage des erwarteten Ergebnisses kann hilfreich sein. Außerdem unterstützt linearLayout nicht layout_alignParentRight. – Ozgur
@Malith Nö können Sie ein Beispiel als Antwort geben? Ich habe versucht, verschiedene Layouts in Layouts mit horizontaler Ausrichtung und andere aber nicht Raster – TwoThumbSticks