0

I've got one question. I designed layout for movie details and it looks like this: enter image description here

Now, I want to add movie description when user scroll down (so this layout stays the same, but when user scrolls it will display movie description). Current layout is wrapped in LinearLayout (vertical). How could I implement that scroll ? I tried to add scroll view as parent but it stretches this layout down...

Here is code by now ...

<?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
  • 2
    Can you place what you've done so far so we can have a clue on how to help you? Commented Sep 25, 2017 at 14:40
  • I added code .. Commented Sep 25, 2017 at 20:35

2 Answers 2

1

For Your Description only, simply use a NestedScrollView. Make sure that the height and width of NestedScrolllView are the ones that you originally used for your description TextView. Then Simply place the TextView in the NestedScrollView. Read more about nestedScrollView here

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

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

Sign up to request clarification or add additional context in comments.

1 Comment

if my answer solved your question, please mark it as correct, so that it will help any other person who has this same question
0

Use something like this

<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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.