【发布时间】:2012-09-22 07:24:56
【问题描述】:
我有一个与在 android 中滚动相关的小问题。这是我的xml文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<VideoView
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:id="@+id/video"
/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="invisible"
android:id="@+id/channelview" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/back"
android:layout_alignParentLeft="true"
android:id="@+id/backbtn"
/>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/backbtn"
android:layout_toLeftOf="@+id/nextbtn"
android:id="@+id/scroll" >
<LinearLayout
android:id="@+id/imageholder"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/next"
android:layout_alignParentRight="true"
android:id="@+id/nextbtn"
/>
</RelativeLayout>
问题是我正在向线性布局动态添加 Imageviews(超过 50 个),我不确定如何通过单击水平滚动视图两侧添加的下一个和上一个按钮来使其滚动。默认情况下,如果我在滚动视图上滑动它会滚动,但我也想通过单击按钮来滚动任何一种方式。谁能建议我如何使用示例代码完成它。谢谢。
【问题讨论】:
-
嗨,我知道这个问题已经很老了。但我是否也在寻找相同的功能。你找到解决办法了吗?
标签: android android-layout button scroll scrollview