2017-12-26 7 views
0

Ich habe die folgende RelativeView. Ich möchteEinige Ansichten nicht in RelativeLayout

  • EditText unten
  • Textview on top - Ich habe ein Problem hier - es nicht zeigen, aber ich verstehe nicht, warum
  • 2 Listviews zwischen ihnen - beide nehmen die Hälfte des Bildschirms vertikal

Bitte sehen Sie, warum diese Top TextView nicht angezeigt wird?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <EditText 
     android:id="@+id/Search" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="text" 
     android:layout_alignParentBottom="true"> 
     <requestFocus /> 
    </EditText> 
    <View android:id="@+id/Placeholder" 
     android:layout_height="0dp" 
     android:layout_width="0dp" 
     android:layout_above="@id/Search" 
     android:layout_centerInParent="true"/> 
    <ListView 
     android:id="@+id/ResultsColumn1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignRight="@id/Placeholder" 
     android:layout_above="@id/Search" /> 
    <ListView 
     android:id="@+id/ResultsColumn2" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignLeft="@id/Placeholder" 
     android:layout_above="@id/Search"/> 
    <TextView 
     android:id="@+id/InformationTextTop" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/ResultsColumn1" 
     android:text="Why is this not visible ?"/> 
</RelativeLayout> 

Antwort

1

Es ist einfach, weil die ListView s match_parent im android:layout_height Eigenschaft haben, und die TextView nach ihnen in der XML definiert. Da dies ein ziemlich einfaches Layout ist, würde ich empfehlen, stattdessen die LinearLayout zu verwenden.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
    <TextView 
     android:id="@+id/InformationTextTop" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/ResultsColumn1" 
     android:text="Why is this not visible ?"/> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 
     <ListView 
      android:id="@+id/ResultsColumn1" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1"/> 
     <ListView 
      android:id="@+id/ResultsColumn2" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1"/> 
    </LinearLayout> 

    <EditText 
     android:id="@+id/Search" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="text"> 
     <requestFocus /> 
    </EditText> 
</LinearLayout> 
Verwandte Themen