Android Studio-HorizontalScollView未移动
我正在上安卓工作室的课程。作为其中的一部分,我正在开发一个模拟音乐播放器应用程序。应用程序应该主要是XML,因为不需要添加功能。 我正在尝试构建e Discover(新音乐)屏幕,在那里您可以看到类似媒体的视图。为此,我想实现一个HorizontalScrollView。 问题是我的滚动视图没有移动。xml代码在我看来很好,我也在谷歌上搜索了一下,但没有找到任何对我的情况有帮助的东西 请对此作出澄清。这是我的密码:Android Studio-HorizontalScollView未移动,android,android-layout,horizontalscrollview,Android,Android Layout,Horizontalscrollview,我正在上安卓工作室的课程。作为其中的一部分,我正在开发一个模拟音乐播放器应用程序。应用程序应该主要是XML,因为不需要添加功能。 我正在尝试构建e Discover(新音乐)屏幕,在那里您可以看到类似媒体的视图。为此,我想实现一个HorizontalScrollView。 问题是我的滚动视图没有移动。xml代码在我看来很好,我也在谷歌上搜索了一下,但没有找到任何对我的情况有帮助的东西 请对此作出澄清。这是我的密码: <?xml version="1.0" encoding="utf-8"?
<?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>
我运行了上面的代码,默认情况下它可以工作。 我认为问题在于,如果布局完全适合屏幕,那么您可能无法看到滚动条。 建议在更小的屏幕上测试
备注:没有足够的评论代表。我运行了上面的代码,默认情况下它可以工作。 我认为问题在于,如果布局完全适合屏幕,那么您可能无法看到滚动条。 建议在更小的屏幕上测试
注意:没有足够的评论代表。请按如下方式更改HorizontalScrollView
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:padding="5px"
android:scrollbars="horizontal">
请按如下方式更改水平滚动视图
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:padding="5px"
android:scrollbars="horizontal">
代码运行良好很酷,谢谢!我的问题是,我在预览模式下查看它,而HorizontalScrollView不起作用。代码工作得很好很酷,谢谢!我的问题是,我在预览模式下查看它,而HorizontalScrollView无法工作。感谢您的帮助!问题是,如果我尝试在模拟设备上运行应用程序,应用程序会不断崩溃,并出现以下错误:“Vibes已停止”或“系统UI不工作”。我也不能在物理设备上运行它,因为我只有一部iPhone。。。(我需要尽快得到一个测试设备)…另外请注意,垂直滚动在预览模式下工作,但水平滚动不工作。感谢您的帮助!问题是,如果我尝试在模拟设备上运行应用程序,应用程序会不断崩溃,并出现以下错误:“Vibes已停止”或“系统UI不工作”。我也不能在物理设备上运行它,因为我只有一部iPhone。。。(我需要尽快得到一个测试设备)…另外请注意,垂直滚动在预览模式下工作,但水平滚动不工作。这样做了,但似乎没有改变任何事情。。。我认为问题在于,我正在预览模式下观察模拟设备不断崩溃…首先解决所有错误并运行它,检查您是否无法获得所需的输出。remove android:fillViewport=“true”无需使用RelativeLayout删除您的约束Layout,它将起作用。你有没有为约束调整过?你做了调整,但似乎没有改变什么。。。我认为问题在于,我正在预览模式下观察模拟设备不断崩溃…首先解决所有错误并运行它,检查您是否无法获得所需的输出。remove android:fillViewport=“true”无需使用RelativeLayout删除您的约束Layout,它将起作用。你有没有调整过约束条件??