Android实战之Scrollbar Activity
2010-10-20 21:37
441 查看
Android中几个常用的Layout虽然有scrollbar属性,但是并不能实现当其中内容太多时自动在Activity上出现Scrollbar,后来发现对于这种情况其实是需要使用ScrollView来处理的,具体配置可以如下:
或者
其中需要注意的是ScrollView内部只能有一个子元素,所以需要把所有的子元素放到一个LinearLayout内部。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id_scrollbar/layout1" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > ... </LinearLayout> </ScrollView> </LinearLayout>
或者
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" > ... </LinearLayout> </ScrollView>
其中需要注意的是ScrollView内部只能有一个子元素,所以需要把所有的子元素放到一个LinearLayout内部。
相关文章推荐
- Android实战之Scrollbar Activity
- Android如何给无法更改继承关系的Activity更换ActionBar(setContentView方法实战)
- Android控件之ScrollView(scrollbarStyle)
- android 建立的activity不自带titlebar,并且用TimePicker和DataPicker中XML文件显示的和手机屏幕上不一致
- android 切换到有ScrollView +Gridview 或者listview 布局的Activity时会上拉一点
- AndroidGUI25:定制Activity的标题栏(Titlebar)
- Android:定制Activity的标题栏(Titlebar)
- Android实战 - 音心播放器 (MusicListActivity - 音乐播放和MainActivity的一个问题)
- Android简易实战教程--第四十四话《ScrollView和HorizontalScrollView简单使用》
- Android Scroll详解(二):OverScroller实战
- Android 自定义Activity的标题栏(Titlebar)
- Android实战简易教程-第四枪(ScrollView和HorizontalScrollView动态添加控件并提供事件监听)
- Android实战技巧之二十八:启动另一个App/apk中的Activity
- Android简易实战教程--第四十四话《ScrollView和HorizontalScrollView简单使用》
- AbsListView android:smoothScrollbar
- (android实战)判断当前task中的运行的activity是否为当前应用
- Android的Activity屏幕切换动画(二)-左右滑动深入与实战
- Android的Activity屏幕切换动画(二)-左右滑动深入与实战
- android:scrollbarStyle属性及滚动条和分割线覆盖问题
- Android 设置Activity全屏显示,没有TitleBar;自定义TitleBar