第一个android客户端笔记
2015-08-30 17:07
441 查看
主页面
采用时下比较流行的主页面框架,bottomTap加Fargment组成.最初有考虑的是ViewPager,不过考虑到中间的页面还是不要左右滑动的好,使用Fragment来实现.
整体布局为SwipeRefreshLayout加listView组成.
main_layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.erlema.activity.MainActivity" > <FrameLayout android:id="@+id/main_fragment" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" /> <include layout="@layout/tap_layout"/> </LinearLayout>
第一个页面的Fragment布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ViewStub android:id="@+id/loadinglayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:layout="@layout/loading" /> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/indext_swp" android:layout_width="match_parent" android:layout_height="match_parent" > <ListView android:id="@+id/mytopic" android:layout_width="match_parent" android:layout_height="0dp" android:focusable="true" android:focusableInTouchMode="true" android:layout_weight="1" > <requestFocus /> </ListView> </android.support.v4.widget.SwipeRefreshLayout> </LinearLayout>
可以看到,上面可以左右滑动的图片轮播并没有出现在FragMent的布局中,因为我想要的效果是整个页面可以向上滑动,包括上面的ViewFLipper.
最初的布局是用一个ScrollLayout将viewFlipper和listview都包含进去,但listView和ScrollLayout组合时出现了bug,listView 只能显示一行,给listView设置具体的高度时又发现顶部的viewflipper并不会随之滚动. 在百度了一轮后发现有人建议将ViewFLipper当做Headveiw加载到listVew中去,发现效果不错便使用了.
顺便说下,SwipeRefreshLayout 和listView貌似也有冲突,当swipeRefresh正在刷新时点击listview会出现程序崩溃的现象.不知道有没有大神能告诉我原因.我暂时的解决方法是当他正在刷新时将lsitveiw的enable设为false.
新的问题又来了.由于第一次使用Viewflipper,发现他给的接口真的很少,比如发现没有接听页面滚动改变的接口,这让我的图片指示器不知如何实现.网上有人使用自定义Viewflipper来实现,可是我自定义view还不是很熟悉.无意中发现有人在Viewflipper的进入动画中实现图片指示器,感觉很符合我的心意.
viewFlipper.getInAnimation().setAnimationListener( new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { <strong> SetMark(viewFlipper.getDisplayedChild());</strong> }
暂时记录到此.等待代码继续完善后回来记录.
相关文章推荐
- Android Drawable系列(1):自定义背景以及注意事项
- Android四大组件之Service
- Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用
- Android开发——Activity生命周期中的一些注意点
- android播放音频文件(MediaPlayer)和录音(MediaRecorder)--播放音频文件
- Android-Android studio 出现 Error: NDK integration is deprecated in the current plugin. 问题解决
- android开发环境搭建
- Android自学笔记之ToggleButton(开关按钮)的功能、特殊属性、用法
- android无法运行 adb.exe和模拟器不显示hello word
- Android数据缓存方案
- 我总结的Android编程规范
- Android-手势识别(自定义手势识别:四种自定义手势)
- Android常用加密算法比较
- Activity的启动模式
- 转发离线安装 Android Studio 更新
- Android(java)学习笔记203:网页源码查看器(Handler消息机制)
- DES的加密与解密(可逆)
- Android视频教程分享
- Android Listview横向滑动
- android服务调用