Elemente im Layout rechts ausrichten

  • Antworten:3
foren.junkie
  • Forum-Beiträge: 6

09.08.2016, 19:56:13 via Website

Hallo Leute,

habe eine ListView mit die eine View pro zeile anzeigen soll. Das Layout für diese View ist in einer separaten xml angelegt und will folgende Ansicht erstellen:
zwei kleine TextViews vertikal angeordnet auf der rechten Seite und eine grosse TextView auf der linken, welche den ganzen restlichen Platz ausfüllen soll und in der Zeile (vertikal gesehen) zentriert dargestellt werden soll.
Das Layout wird im AndriodStudio genau so angezeigt wie ich diesen haben will, jedoch im Emulator oder auch auf meinem Android-Gerät ist die grosse TextView lediglich so lang, wie der Text darin. Hier meine (fragment) xml datei:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="hakunamatata"
    android:id="@+id/llProcessOverviewLine"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/tvDescription"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.90"
        android:layout_gravity="center_vertical"
        android:paddingLeft="10dp"
        android:textSize="16dp"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceLarge"
 />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:layout_gravity="center_vertical">

        <TextView
            android:id="@+id/tvStatus"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="10dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@android:color/holo_green_dark" />

        <TextView
            android:id="@+id/tvProgress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="10dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@android:color/holo_red_light"
            android:layout_gravity="right"/>
    </LinearLayout>

</LinearLayout>

Kann mir jemand sagen, wie ich dem Android verklickere wie er das machen soll?

Viele Grüsse
junkie

— geändert am 09.08.2016, 19:57:10

Antworten
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

09.08.2016, 21:16:16 via App

Schau dir mal das LayoutWeight attribut an

LG Pascal //It's not a bug, it's a feature. :) ;)

Antworten
foren.junkie
  • Forum-Beiträge: 6

09.08.2016, 21:27:41 via Website

schon mehrmals. 0.9 zu 0.1 genau so war es gedacht

Antworten
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

09.08.2016, 21:46:17 via App

Lass mal das Layout width ganz weg oder so:
http://stackoverflow.com/a/11965757

LG Pascal //It's not a bug, it's a feature. :) ;)

Antworten