2017-09-25 5 views
0

Ich habe eine Frage. Ich entwarf das Layout für Film Details und es sieht wie folgt aus: enter image description hereImplementierung von ScrollView Android?

Nun, ich möchte Filmbeschreibung hinzufügen, wenn der Benutzer nach unten scrollen (so das Layout gleich bleibt, aber wenn Benutzer einen Bildlauf wird es Filmbeschreibung angezeigt werden). Das aktuelle Layout ist in LinearLayout (vertikal) eingeschlossen. Wie könnte ich diese Schriftrolle implementieren? Ich habe versucht, scroll Ansicht als Eltern hinzuzufügen, aber es erstreckt sich dieses Layout auf ...

Hier Code jetzt ...

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:weightSum="10"> 


    <ImageView 
     android:id="@+id/iv_backdrop" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="4" 
     android:scaleType="centerCrop" /> 

    <LinearLayout 
     android:id="@+id/layout_favorite" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="-40dp" 
     android:gravity="right"> 

     <RelativeLayout 
      android:layout_width="100dp" 
      android:layout_height="80dp" 
      android:layout_marginEnd="25dp"> 

      <ImageView 
       android:id="@+id/iv_background_favorite" 
       android:layout_width="100dp" 
       android:layout_height="80dp" 
       android:layout_alignParentStart="true" 
       android:layout_alignParentTop="true" 
       android:tint="#000000" 
       app:srcCompat="@drawable/ic_ellipse" /> 

      <ImageView 
       android:id="@+id/iv_foreground_favorite" 
       android:layout_width="65dp" 
       android:layout_height="45dp" 
       android:layout_centerInParent="true" 
       android:layout_centerVertical="true" 
       app:srcCompat="@drawable/ic_favorite_border_white_36px" /> 


     </RelativeLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/layout_short_desc" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_marginTop="-20dp" 
     android:layout_weight="4"> 

     <ImageView 
      android:id="@+id/iv_poster" 
      android:layout_width="150dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left" 
      android:layout_marginStart="20dp" 
      android:adjustViewBounds="true" 
      android:scaleType="fitCenter" /> 

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

      <TextView 
       android:id="@+id/tv_title" 
       android:layout_width="150dp" 
       android:layout_height="wrap_content" 
       android:layout_marginStart="20dp" 
       android:textSize="19sp" 
       android:textStyle="bold" /> 

      <TextView 
       android:id="@+id/tv_tagline" 
       android:layout_width="160dp" 
       android:layout_height="wrap_content" 
       android:layout_marginStart="20dp" 
       android:layout_marginTop="8dp" 
       android:textSize="16sp" 
       android:textStyle="italic" /> 

      <TextView 
       android:id="@+id/tv_movie_released" 
       android:layout_width="160dp" 
       android:layout_height="wrap_content" 
       android:layout_marginStart="20dp" 
       android:layout_marginTop="8dp" 
       android:text="12-12-2007(Released)" 
       android:textAlignment="viewStart" 
       android:textAllCaps="false" 
       android:textSize="16sp" /> 

      <TextView 
       android:id="@+id/tv_movie_duration" 
       android:layout_width="160dp" 
       android:layout_height="wrap_content" 
       android:layout_marginStart="20dp" 
       android:layout_marginTop="8dp" 
       android:text="Duration - 90 min" 
       android:textSize="16sp" /> 
     </LinearLayout> 

    </LinearLayout> 

    <View 
     android:id="@+id/v_separator" 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:layout_marginLeft="25dp" 
     android:layout_marginRight="25dp" 
     android:layout_marginTop="20dp" 
     android:background="@android:color/darker_gray" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="2" 
     android:weightSum="4"> 

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

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

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_centerInParent="true" 
        android:layout_margin="20dp" 
        android:src="@drawable/hexagon" /> 

       <TextView 
        android:id="@+id/tv_vote_average" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerInParent="true" 
        android:layout_gravity="center_horizontal" 
        android:textColor="#ffffff" 
        android:textSize="16sp" /> 

       <TextView 
        android:id="@+id/tv_number_votes" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:gravity="center_horizontal" 
        android:textColor="#000000" 
        android:textSize="16sp" /> 

      </RelativeLayout> 


     </LinearLayout> 

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

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

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_margin="20dp" 
        android:adjustViewBounds="true" 
        android:src="@drawable/theatre" /> 

       <TextView 
        android:id="@+id/tv_genre" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:gravity="center_horizontal" 
        android:textColor="#000000" 
        android:textSize="16sp" /> 
      </RelativeLayout> 


     </LinearLayout> 

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

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

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_centerInParent="true" 
        android:layout_margin="20dp" 
        android:src="@drawable/circle_double_border" /> 

       <TextView 
        android:id="@+id/tv_popularity" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:layout_gravity="center_horizontal" 
        android:textColor="#ffffff" 
        android:textSize="16sp" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:gravity="center_horizontal" 
        android:text="Popularity" 
        android:textColor="#000000" 
        android:textSize="16sp" /> 
      </RelativeLayout> 
     </LinearLayout> 

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

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

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_centerInParent="true" 
        android:layout_margin="20dp" 
        android:src="@drawable/circle_double_border" /> 

       <TextView 
        android:id="@+id/tv_language" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerInParent="true" 
        android:layout_gravity="center_horizontal" 
        android:textColor="#ffffff" 
        android:textSize="16sp" /> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:gravity="center_horizontal" 
        android:text="Language" 
        android:textColor="#000000" 
        android:textSize="16sp" /> 
      </RelativeLayout> 

     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 
+2

Können Sie platzieren, was Sie bisher getan haben, so können wir eine Ahnung haben, wie man helfen Du? – Rob

+0

Ich habe Code hinzugefügt .. –

Antwort

1

für die Beschreibung nur einfach eine NestedScrollView verwenden. Stellen Sie sicher, dass die Höhe und Breite von NestedScrolllView diejenigen sind, die Sie ursprünglich für Ihre Beschreibung TextView verwendet haben. Dann platzieren Sie einfach die TextView in der NestedScrollView. Lesen Sie mehr über nestedScrollView hier

https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html

http://www.devexchanges.info/2016/07/nested-scroll-views-in-android.html

+0

Wenn meine Antwort Ihre Frage gelöst hat, bitte markieren Sie es als richtig, so dass es jeder anderen Person helfen wird, die diese gleiche Frage hat –

0

Verwendung so etwas wie dieses

<ScrollView>   //Should be on top 
    <RelativeLayout>   //Scroll View Contains only child view 
     <RelativeLayout> 
      //Paste your whatever so far created views. 
     </RelativeLayout> 

     <RelativeLayout> 
      //Place your Description view here 
     </RelativeLayout> 
    </RelativeLayout> 
</ScrollView>