Android 中视频和文本布局的滚动视图
Scrollview for Video and Text layout in Android
我制作了一种布局,我在顶部声明了视频,然后在其下方声明了文本。现在我可以使文本滚动,但视频仍保持在顶部。我希望视频+文本可以滚动。
为了实现这一点,我已经以某种方式做到了,但我不认为这是一个好方法。我创建了两个 XML 文件,在其中一个文件中,我将视频放在最上面,将文本放在下面。其次,我调用了这个布局并使其成为带有滚动的列表视图。告诉我一个干净的方法来实现视频和文本的滚动。
试试这个:
<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" >
<VideoView
android:id="@+id/video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</VideoView>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/your_text" >
</TextView>
</LinearLayout>
</ScrollView>
我制作了一种布局,我在顶部声明了视频,然后在其下方声明了文本。现在我可以使文本滚动,但视频仍保持在顶部。我希望视频+文本可以滚动。
为了实现这一点,我已经以某种方式做到了,但我不认为这是一个好方法。我创建了两个 XML 文件,在其中一个文件中,我将视频放在最上面,将文本放在下面。其次,我调用了这个布局并使其成为带有滚动的列表视图。告诉我一个干净的方法来实现视频和文本的滚动。
试试这个:
<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" >
<VideoView
android:id="@+id/video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</VideoView>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/your_text" >
</TextView>
</LinearLayout>
</ScrollView>