android ScrollView--Linearlayout可以上下拖动
16lz
2021-01-23
动态添加:
[java] view plain copy
[java] view plain copy
- <?xmlversion="1.0"encoding="utf-8"?>
- <ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:scrollbars="vertical"
- android:fadingEdge="vertical">
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- >
- </LinearLayout>
- </ScrollView>
动态代码上:
scrollView=new ScrollView(getApplicationContext());
scrollView.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_dark));
scrollView.setScrollbarFadingEnabled(true);
scrollview.addView(XXXX);
值得一提的是XXX只能是一个总的控件或者一个子控件,如果直接添加两个子控件会报错。
更多相关文章
- Android 动态注册监听网络变化实例详解
- android 界面控件被输入法顶起来解决
- [置顶] [Android自定义控件]Android中如何用代码写出优美的Button
- Android在程序中动态生成控件,动态布局
- Android:横行滚动且隔行变色的ListView控件
- Android 动态设置全屏,退出全屏
- Android下拉刷新上拉加载控件的使用
- Android实现动态切换横竖屏,保存横竖屏数据(用Preference存储)
- Android space控件:间隙留白