I am doing some Android Studio courses. As part of this I am working on a mock-up music player app. The app should be mostly XML as not functionality needs to be added. I am trying to build e Discover (new music) screen, where you have media like views. To do this, I want to implement an HorizontalScrollView. The problem is that my scroll view doesn't move. The xml code looks fine to me and I also googled this but did not find anything that would help my situation.
Would very much appreciate some clarification on this. Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayoutxmlns: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="com.example.alexcojocaru.vibes.Discover">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Recommendations"
android:textColor="#cc3300" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true"
android:padding="5px"
android:scrollbars="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:padding="5px"
android:src="@drawable/bear" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="My Name is Bear"
android:textColor="#000000"
android:textSize="11sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Nahko"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="13px">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:padding="6px"
android:src="@drawable/omam" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Beneath The Skin"
android:textColor="#000000"
android:textSize="11sp" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Of Monsters and Men"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="13px">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:padding="6px"
android:src="@drawable/jmj" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Essential Recollection"
android:textColor="#000000"
android:textSize="11sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Jean-Michel Jarre"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="13px">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:padding="6px"
android:src="@drawable/ram" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Random Access Memories"
android:textColor="#000000"
android:textSize="11sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5px"
android:text="Daft Punk"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</LinearLayout>
I ran the above code and it works by default. I think the problem is that if the layout fits fully on screen then you might not be able to see the scroll. Suggesting to test on a smaller screen.
P.S:Not enough rep for comments.