SwipeRefreshLayout中嵌套RelativeLayout或者LinearLayout的异常
来源:互联网 发布:多传感器数据融合改进 编辑:程序博客网 时间:2024/06/06 06:34
今天项目需要写一个界面,大致的布局是SwipeRefreshLayout中嵌套RelativeLayout,代码如下:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/swipe_refresh_widget" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fffff5dc" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" 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="com.xiaoxin.mydemo.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> </RelativeLayout></android.support.v4.widget.SwipeRefreshLayout>
但是发现下拉刷新时会出现动画被打断现象。
后来发现嵌套LinearLayout也会出现同样的情况。一直没有找到什么原因
最终解决方案是在LineraLayout外面包一层ScrollView ,完美解决问题,具体原因要看源码才能知道,知道原因的朋友也可以告诉我。如下代码:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/swipe_refresh_widget" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fffff5dc" android:orientation="vertical"> <ScrollView android:id="@+id/content_main" android:layout_width="match_parent" android:layout_height="match_parent" android:fadingEdge="none" android:overScrollMode="never" android:scrollbars="none"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" 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="com.xiaoxin.mydemo.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> </RelativeLayout> </ScrollView></android.support.v4.widget.SwipeRefreshLayout>
1 0
- SwipeRefreshLayout中嵌套RelativeLayout或者LinearLayout的异常
- Android应用的LinearLayout中嵌套RelativeLayout的布局用法
- Android中LinearLayout、RelativeLayout、TableLayout、AbsoluteLayout容器的使用
- Android中LinearLayout、RelativeLayout、TableLayout、AbsoluteLayout容器的使用
- Android中RelativeLayout与LinearLayout的性能分析
- 【Android性能优化】尽可能用RelativeLayout来代替多层嵌套的LinearLayout
- LinearLayout和RelativeLayout的比较
- RelativeLayout与LinearLayout的比较
- linearLayout 和 relativeLayout的区别
- RelativeLayout与LinearLayout的比较
- RelativeLayout与LinearLayout的区别
- RelativeLayout和LinearLayout的属性
- RelativeLayout与LinearLayout的比较
- LinearLayout和RelativeLayout的使用
- LinearLayout的嵌套使用
- Android中LinearLayout与RelativeLayout属性解说
- Android中LinearLayout和RelativeLayout使用详解
- 动态中添加LinearLayout和RelativeLayout布局
- python实例1:创建一个登陆模块
- iOS一行代码让你的应用中UIScrollView的滑动与侧滑返回并存
- 基于BaseAdapter的安卓百变Adapter实现
- 介绍X-MODEM协议和Y-MODEM,Z-MODEM的区别
- Oracle日期加减计算 方法汇总
- SwipeRefreshLayout中嵌套RelativeLayout或者LinearLayout的异常
- eclipse常用操作
- 树莓派大家各类服务器
- eclipse安装svn失败得解决方法
- VMware虚拟机启动报错,无法执行64位操作
- 第十周 项目三-树和二叉树的例题
- xilinx sdk 中显示代码行号
- MySQL常用函数系列之一:字符串函数(1)
- 大型网站技术架构(1)