您的位置:首页 > 编程语言

安卓编程应用-ScrollView垂直滚动和HorizontalScrollView水平滚动。

2014-04-11 20:13 579 查看
[align=center]ScrollView垂直滚动和HorizontalScrollView水平滚动。[/align]
滚动视图(为控件或者布局添加滚动条):屏幕显示不完时,可通过滚动来显示视图。

ScrollView垂直滚动和HorizontalScrollView水平滚动。

这两个控件只能有一个孩子,它并不是传统意义上的容器。

activity_main.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="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent" >

<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent" >

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/picture01" />
<!-- picture01最好是一个操作屏幕的大图片 -->
</ScrollView>
</HorizontalScrollView>

</RelativeLayout>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: