2016-08-27 2 views
1

Das ist mein Activity.xml Layout ein Fragment enter code here Fragment enthält Listview nicht vollständig auf meine Tätigkeit erscheint

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

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

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:id="@+id/txt_title" 
      android:text="Chappie" 
      android:textSize="30dp" 
      android:textStyle="bold" 
      android:paddingTop="20dp" 
      android:paddingLeft="20dp" 
      android:background="#000" 
      android:textColor="#FFFFFF" 


      /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:orientation="horizontal" 
      > 
      <ImageView 
       android:id="@+id/Image_Poster" 
       android:layout_width="0dp" 
       android:layout_weight="1" 
       android:layout_height="match_parent" 
       android:layout_marginLeft="20dp" 
       /> 

      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="0dp" 
       android:layout_weight="2" 
       android:layout_height="match_parent"> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1" 
        android:id="@+id/txt_release_date" 
        android:text="2015" 
        android:textSize="18dp" 
        android:layout_marginLeft="40dp" 
        android:layout_marginTop="10dp" 
        android:textStyle="bold" 
        /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1" 
        android:id="@+id/txt_VoteAverage" 
        android:text="8.1/10" 
        android:textSize="18dp" 
        android:layout_marginLeft="40dp" 
        android:layout_marginTop="2dp" 
        android:textStyle="bold" 
        android:textColor="#000"/> 
       <RatingBar 
        android:id="@+id/ratingBar" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:numStars="1" 
        android:stepSize="1.0" 
        android:rating="1.0" 
        android:layout_marginLeft="35dp" 
        android:layout_marginBottom="10dp" 
        /> 
      </LinearLayout> 

     </LinearLayout> 

     <TextView 
      android:textColor="#CDC5B4" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:id="@+id/txt_overview" 
      android:text="Every child comes into the world full of promise, and non more than Chappie:he is gifted, special, a prodigy. Chappie he is a robot." 
      android:padding="20dp" 
      android:textSize="15dp" 
      android:textStyle="bold" 
      /> 
     <fragment 
      android:layout_weight="2" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:id="@+id/TrailersFragment" 
     android:name="com.example.prof_mohamed.movieapp.TrailersFragment"/> 

    </LinearLayout> 
</ScrollView> 
</LinearLayout> 

mein Fragment Layout trailers_fragment.xml Datei

enter code here

enthält enthält
<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent"  
    android:layout_height="match_parent" 
    android:paddingLeft="14dp" 
    android:paddingTop="16dp" 
    android:paddingBottom="16dp"> 

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

    <TextView 

     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="see Reviews" 
     android:id="@+id/seeReviews" 
     /> 
    </FrameLayout> 

nach dem Aufblasen von trailers_fragment.xml Layout auf meinem ac Es läuft alles, aber meine Listenansicht zeigt nur den ersten Eintrag und die restlichen Einträge verschwinden. kann mir jemand sagen, wie ich mein fragment ansprechend auf die anzahl der listview-artikel meiner aktivität anpasse? Ihre Antwort wird geschätzt. Danke

+0

Änderung finden die 'ListView' Höhe' wrap_content' –

+0

diese Lösung löst das Problem nicht, es existiert noch! –

+0

Sie können nicht ListView in ScrollView verwenden, das ist Ihr Problem. Sie müssen Ihr Layout vollständig ändern. –

Antwort

0

Sie sollten Ihr ursprüngliches Problem ist etwas anderes verwenden wrap_content oder Gewicht in der Fragment-Layout

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent"  
    android:layout_height="match_parent" 
    android:paddingLeft="14dp" 
    android:paddingTop="16dp" 
    android:paddingBottom="16dp"> 

<ListView 
     android:id="@+id/listview_trailers" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

    <TextView 

     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="see Reviews" 
     android:id="@+id/seeReviews" 
     /> 
    </FrameLayout> 
+0

Nein Liebe, diese Lösung hat das Problem nicht optimiert. Das Problem besteht immer noch !! –

0

Ich vermute. Der ListView bläht alle Objekte auf, aber nur sein erstes Objekt ist für Sie sichtbar und Sie können nicht nach oben scrollen, um die anderen Objekte zu sehen.

Das Problem liegt an einer Listview (In Fragment) in einem ScrollView.

Der in der ScrollView gehaltene ListView dehnt sich nicht auf seine volle Höhe aus. Außerdem implementiert ListView seinen eigenen ScrollListener. Aber hier erhält ListView keine Scroll-Geste, da es von Parent ScrollView gehandhabt wird.

Daher würde ich Ihnen empfehlen, Ihre Scroll zu entfernen und die Linearlayout als Header eines Listview hinzuzufügen oder einige andere praktische Lösung

Dank

Verwandte Themen