-1

Ich versuche, zwei Textansichten unten rechts zu fixieren und über der Listenansicht zu halten. Wenn die Listenansicht leer ist, möchte ich sie unten rechts korrigieren, aber mit diesem Code verschwindet die Textansicht, wenn ich einige Elemente zur Listenansicht hinzufüge. Layout ImageTextView auf unten rechts setzen

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <LinearLayout 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/relativeLayout1"> 
     <Button 
      android:text="Fechar Comanda" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnFecharComanda" /> 
     <Button 
      android:text="Extrato" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnExtrato" /> 
     <Button 
      android:text="Enviar Cozinha" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnEnviarCozinha" /> 
     <Button 
      android:text="Anterior" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnAnterior" /> 
    </LinearLayout> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/linearLayout1" 
     android:weightSum="100"> 
     <ListView 
      android:id="@+id/sportsList" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:entries="@array/primeira" 
      android:layout_weight="33" /> 
     <ListView 
      android:id="@+id/sportsList_1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:entries="@array/segunda" 
      android:layout_weight="34" /> 
     <LinearLayout 
      android:orientation="vertical" 
      android:layout_weight="33" 
      android:id="@+id/linearLay123123" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:weightSum="100"> 
      <ListView 
       android:id="@+id/sportsList_2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:entries="@array/terceira" /> 
      <LinearLayout 
       android:orientation="vertical" 
       android:id="@+id/odkjfs" 
       android:layout_width="match_parent" 
       android:layout_height="100px" 
       android:gravity="bottom"> 
       <TextView 
        android:text="Total" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/textView2" 
        android:gravity="end" 
        android:layout_marginRight="10dp" /> 
       <TextView 
        android:text="R$15" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:id="@+id/textView1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="end" 
        android:layout_marginRight="10dp" 
        android:layout_marginBottom="10dp" /> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

Antwort

0

So haben Sie Ihre Frage mit ReleativeLayout, getaggt, die die Lösung für Ihr Problem ist das, was ist. Sie benötigen linearLay123123 zu einem RelativeLayout und sagen Sie dem Layout-System zu ändern, dass Sie immer odkjfs am unteren rechten wollen und Ihre ListViewsportsList_2 darüber:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <LinearLayout 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/relativeLayout1"> 
     <Button 
      android:text="Fechar Comanda" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnFecharComanda" /> 
     <Button 
      android:text="Extrato" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnExtrato" /> 
     <Button 
      android:text="Enviar Cozinha" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnEnviarCozinha" /> 
     <Button 
      android:text="Anterior" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/btnAnterior" /> 
    </LinearLayout> 
    <LinearLayout 
     android:orientation="horizontal" 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/linearLayout1" 
     android:weightSum="100"> 
     <ListView 
      android:id="@+id/sportsList" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:entries="@array/primeira" 
      android:layout_weight="33" /> 
     <ListView 
      android:id="@+id/sportsList_1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:entries="@array/segunda" 
      android:layout_weight="34" /> 
     <RelativeLayout 
      android:layout_weight="33" 
      android:id="@+id/linearLay123123" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <ListView 
       android:id="@+id/sportsList_2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true" 
       android:layout_above="@+id/odkjfs" 
       android:entries="@array/terceira" /> 
      <LinearLayout 
       android:orientation="vertical" 
       android:id="@+id/odkjfs" 
       android:layout_width="match_parent" 
       android:layout_height="100px" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentRight="true"> 
       <TextView 
        android:text="Total" 
        android:textAppearance="?android:attr/textAppearanceSmall" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/textView2" 
        android:gravity="end" 
        android:layout_marginRight="10dp" /> 
       <TextView 
        android:text="R$15" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:id="@+id/textView1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:gravity="end" 
        android:layout_marginRight="10dp" 
        android:layout_marginBottom="10dp" /> 
      </LinearLayout> 
     </RelativeLayout> 
    </LinearLayout> 
</LinearLayout> 

Sie Ids sehr schwer so zu erinnern, ich rate Sie, um sie zu ändern.

Aber lassen Sie uns das Layout oben brechen. Sie haben ein äußeres Layout mit zwei Zeilen. Der untere hat drei Spalten. Was du ändern wolltest, ist die Spalte ganz rechts, so dass sie auf der Unterseite davon bestehen bleibt.

Am einfachsten ist es also, von einem LinearLayout zu einem zu wechseln, da es viel einfacher ist, Ansichten aufeinander auszurichten, wie der Name andeutet.

Also nach dem Ändern auf RelativeLayout müssen wir die ListView an die Spitze ausrichten. Und dass es seine Höhe anpassen muss, um über dem Inhalt unten zu sein.

android:layout_alignParentTop="true" 
android:layout_above="@+id/odkjfs" 

Dann auf die LinearLayout dem wollte man unten rechts sein. Wir müssen es sagen, um rechts zu justieren und nach unten zu justieren:

Einfach so.

Verwandte Themen