解决ScrollView与ListView显示冲突问题
来源:互联网 发布:保姆偷喝母乳 知乎 编辑:程序博客网 时间:2024/05/17 02:55
- 自定义ListView 重写其onMeasure(),方法
public class ListViewForScrollView extends ListView{ public ListViewForScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // TODO Auto-generated constructor stub } public ListViewForScrollView(Context context) { super(context); // TODO Auto-generated constructor stub } public ListViewForScrollView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); }}
2.布局文件引用
<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/act_sv" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="\n上方数据\n" /> <com.crazyandroid.custom.ListViewForScrollView android:id="@+id/act_lv" android:layout_width="fill_parent" android:layout_height="wrap_content"> </com.crazyandroid.custom.ListViewForScrollView> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="\n下方数据\n" /> </LinearLayout></ScrollView>
3.java代码
mScrollView = (ScrollView) findViewById(R.id.act_sv);mScrollView.smoothScrollTo(0, 0);//确保ScrollView从顶端显示
4.更多解决方法 请参阅:
http://www.apkbus.com/forum.php?mod=viewthread&tid=161576
0 0
- 解决ScrollView与ListView显示冲突问题
- 滚动条:解决ScrollView与ListView显示冲突问题
- 滚动条:解决ScrollView与ListView显示冲突问题
- 解决scrollview与listview冲突问题
- 解决ScrollView 与listview冲突问题
- 解决scrollview 与 listview 控件冲突问题
- ScrollView与ListView冲突解决
- scrollView与ListView 冲突解决
- ScrollView与ListView冲突解决
- 解决ListView与ScrollView冲突
- Scrollview 与 listview 冲突解决?
- 解决ScrollView嵌套ListView滑动冲突显示不全的问题
- ListView与ScrollView冲突问题
- ScrollView与ListView冲突问题
- 完美解决ScrollView与ListView冲突问题(ListView与ListView的冲突)
- Scrollview与Listview冲突,需要解决什么问题?
- 解决scrollView嵌套listview的冲突问题
- 解决ListView,GrindView和ScrollView冲突问题
- csv 等文件转码
- java中super的用法
- 面向对象 —— 对类(class)的理解
- 百度API———基础地图(一)*
- Nginx源码分析—HTTP框架执行流程
- 解决ScrollView与ListView显示冲突问题
- Selenium+TestNG Web自动化测试环境搭建1_前言
- 做企业网站seo需要避免哪些误区
- DML、DDL、DCL区别
- Dom4j解析和生成XML文档
- VS2013常用快捷键
- android 中的LocalBroadcastManager
- 一步步使用Tomcat+CAS完成单点登录
- Java中的修饰符