2017-04-17 4 views
0

bis unten auf dem Bildschirm füllen Ich habe eine Android-Aktivität, die durch zusammengesetzt ist: FrameLayout> Scroll> Linearlayout> ListviewAndroid Linearlayout

Meine Listview ist meine letzte Komponente, und ich möchte, dass seine Höhe Größe aus der sich gehen würde Ende der vorherigen Komponente bis zum Ende des Bildschirms. Problem: Leider ist seine Größe jetzt nur die Höhe Größe ist nur die Größe von 1 Reihe.

Ich habe alle Layout_Height auf Match_Parent-Eigenschaft festgelegt, aber keinen Effekt.

Frage: Würdest du wissen, wie ich meinen ListView dazu bringen kann, den ganzen Höhenraum bis zum Ende des verfügbaren Bildschirms zu belegen?

Vielen Dank!

XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="it.bitrack.fabio.bitrack.ScheduleView" 
    android:layout_marginTop="60dp"> 

    <!-- TODO: Update blank fragment layout --> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <TextView 
       android:id="@+id/textView7" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:text="Select an asset" 
       android:textStyle="bold|italic" /> 

      <Spinner 
       android:id="@+id/assetSpinner" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:textStyle="bold|italic" /> 

      <LinearLayout 
       android:id="@+id/assetBookingLinearLayout" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

       <TextView 
        android:id="@+id/textView9" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:padding="10dp" 
        android:text="Booking schedule" 
        android:textStyle="bold|italic" /> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="horizontal"> 

        <TextView 
         android:id="@+id/textView12" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:padding="10dp" 
         android:text="From: " 
         android:textStyle="bold|italic" /> 

        <TextView 
         android:id="@+id/fromDatetimeTextView" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="5dp" 
         android:text="Date and time" /> 

        <ImageButton 
         android:id="@+id/setFromDatetimeImageButton" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="5dp" 
         android:src="@android:drawable/ic_menu_my_calendar" /> 

        <TextView 
         android:id="@+id/textView13" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="10dp" 
         android:text="To: " 
         android:textStyle="bold|italic" /> 

        <TextView 
         android:id="@+id/toDatetimeTextView" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="5dp" 
         android:text="Date and time" /> 

        <ImageButton 
         android:id="@+id/setToDatetimeImageButton" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="5dp" 
         android:src="@android:drawable/ic_menu_my_calendar" /> 
       </LinearLayout> 

       <Button 
        android:id="@+id/assetBookingButton" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="Proceed with booking" /> 

      </LinearLayout> 


      <LinearLayout 
       android:id="@+id/assetBookingsLinearLayout" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

       <TextView 
        android:id="@+id/textView8" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:padding="10dp" 
        android:text="Current bookings" 
        android:textStyle="bold|italic" /> 

       <ListView 
        android:id="@+id/assetBookingsListView" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" /> 
      </LinearLayout> 

     </LinearLayout>> 
    </ScrollView> 

</FrameLayout> 

Antwort

0

Verwendung dieses Layout-Code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginTop="60dp"> 

    <!-- TODO: Update blank fragment layout --> 

    <ScrollView 
     android:id="@+id/scrollview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fillViewport="true"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <TextView 
       android:id="@+id/textView7" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:text="Select an asset" 
       android:textStyle="bold|italic" /> 

      <Spinner 
       android:id="@+id/assetSpinner" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="10dp" 
       android:textStyle="bold|italic" /> 

      <LinearLayout 
       android:id="@+id/assetBookingLinearLayout" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

       <TextView 
        android:id="@+id/textView9" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:padding="10dp" 
        android:text="Booking schedule" 
        android:textStyle="bold|italic" /> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="horizontal"> 

        <TextView 
         android:id="@+id/textView12" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:padding="10dp" 
         android:text="From: " 
         android:textStyle="bold|italic" /> 

        <TextView 
         android:id="@+id/fromDatetimeTextView" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="5dp" 
         android:text="Date and time" /> 

        <ImageButton 
         android:id="@+id/setFromDatetimeImageButton" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="5dp" 
         android:src="@android:drawable/ic_menu_my_calendar" /> 

        <TextView 
         android:id="@+id/textView13" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="10dp" 
         android:text="To: " 
         android:textStyle="bold|italic" /> 

        <TextView 
         android:id="@+id/toDatetimeTextView" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="5dp" 
         android:text="Date and time" /> 

        <ImageButton 
         android:id="@+id/setToDatetimeImageButton" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:padding="5dp" 
         android:src="@android:drawable/ic_menu_my_calendar" /> 
       </LinearLayout> 

       <Button 
        android:id="@+id/assetBookingButton" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="Proceed with booking" /> 

      </LinearLayout> 

     </LinearLayout> 
    </ScrollView> 

    <LinearLayout 
     android:id="@+id/assetBookingsLinearLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/scrollview" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/textView8" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="10dp" 
      android:text="Current bookings" 
      android:textStyle="bold|italic" /> 

     <ListView 
      android:id="@+id/assetBookingsListView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </LinearLayout> 

</RelativeLayout> 

Paar Vorschlag:

  1. Dont die Nutzung listview innen ScrollView ...
  2. Verwenden Sie RelativeLayout als Stammelement zum Ausrichten von Ansichten nach anderen.
  3. Für scrollView Verwendung android:layout_height="wrap_content" und android:fillViewport="true"

Ausgang:

enter image description here