在android中滚动单击下一步和上一步按钮
我有一个与android中的滚动相关的小问题。这是我的xml文件在android中滚动单击下一步和上一步按钮,android,android-layout,button,scroll,scrollview,Android,Android Layout,Button,Scroll,Scrollview,我有一个与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
<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>
问题是我正在将ImageView动态(超过50多个)添加到线性布局,我不确定如何通过单击水平滚动视图两侧添加的下一个和上一个按钮使其滚动。默认情况下,如果我在scrollview上滑动,它会滚动,但我也希望通过单击按钮来滚动。有谁能建议我如何使用示例代码完成它。谢谢。这样可以向上或向下滚动滚动滚动视图
scrollview.post(new Runnable() {
@Override
public void run() {
// to scroll down
scrollview.fullScroll(ScrollView.FOCUS_DOWN);
// to scroll up
scrollview.fullScroll(ScrollView.FOCUS_UP);
}
});
这样,滚动视图可以向上或向下滚动
scrollview.post(new Runnable() {
@Override
public void run() {
// to scroll down
scrollview.fullScroll(ScrollView.FOCUS_DOWN);
// to scroll up
scrollview.fullScroll(ScrollView.FOCUS_UP);
}
});
这将使它进入视图的最顶部或最底部。我只想让它前进几步,这会让它走到视图的最顶端或最底端。我只想让它提高一些。嗨,我知道这个问题已经很老了。但我也在寻找同样的功能。你找到解决办法了吗?嗨,我知道这个问题很老了。但我也在寻找同样的功能。你找到解决办法了吗?