Android其它新控件
来源:互联网 发布:木马编程教学 编辑:程序博客网 时间:2024/06/04 20:08
Android其它新控件
欢迎转载,转载请注明原文出处:http://blog.csdn.net/lavor_zl/article/details/51312715,谢谢。
Android其它新控件是指非Android大版本更新时提出的新控件,也非谷歌IO大会提出的新控件,而是谷歌发现市场上某种功能的控件被大量使用,而不定期推出实现该功能的官方控件。Android其它新控件常用的有下面两种。
1. Drawerlayout(抽屉布局)
抽屉布局的使用比较简单,一般在DrawerLayout下面定义两个视图,第一个视图作为主界面,第二个视图作为抽屉,注意第二个视图要设置android:layout_gravity
属性,否则不会作为抽屉,而且我们打开关闭抽屉还和此属性相关。
在xml中定义DrawerLayout
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/refresh" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="sads" /> </android.support.v4.widget.SwipeRefreshLayout> <LinearLayout android:layout_gravity="start" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:ems="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="我是抽屉布局的抽屉部分" /> </LinearLayout></android.support.v4.widget.DrawerLayout>
在java文件中怎么打开,关闭抽屉
//打开Gravity.START位置的抽屉 drawerlayout.openDrawer(Gravity.START); //关闭Gravity.START位置的抽屉 drawerlayout.closeDrawer(Gravity.START);
抽屉关闭状态时:
抽屉打开状态时:
2. SwipeRefreshLayout(滑动刷新布局)
SwipeRefreshLayout使用户可以通过垂直滑动手势刷新视图的内容。
在xml中定义SwipeRefreshLayout
<android.support.v4.widget.SwipeRefreshLayout android:id="@+id/refresh" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="我是主界面部分" /> </android.support.v4.widget.SwipeRefreshLayout>
在java中操作SwipeRefreshLayout
this.refresh = (SwipeRefreshLayout) findViewById(R.id.refresh); refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Log.i("SwipeRefreshLayout","下拉刷新"); //do something,刷新视图内容 refresh.setRefreshing(false);//设置刷新结束 Log.i("SwipeRefreshLayout","刷新完毕"); } });
本程序源代码下载:Android其它新控件
1 0
- Android其它新控件
- Android 新控件RecyclerView
- android 新控件使用
- android design 新控件
- android新控件AppBarLayout,
- Android 继承ListActivity在页面中添加其它控件
- Android开发~点击其它控件弹出软键盘
- 其它新组件
- Android新控件RecyclerView剖析
- TextInputLayout-Android M新控件
- Snackbar-Android M新控件
- TabLayout-Android M新控件
- android兼容包新控件
- Snackbar-Android M新控件
- Android兼容包新控件
- Android 开发的新控件
- Android 新控件学习总结
- android 5.0 6.0新控件
- [BZOJ1189][HNOI2007]紧急疏散evacuate(bfs+二分+最大流)
- 美团酒店Node全栈开发实践
- Android Bug List
- jvm GC日志解读
- tableview有多项选择时 ,只能选中一个,
- Android其它新控件
- 4月书讯:迟来的告白
- 跨平台的移动Web开发实战(HTML5+CSS3)
- PHP json_encode 中, json的values中开头有换行的问题
- Java生成随机数,几千年不重复哦
- 同时安装了office2003和office2010,如何设置office2003为默认打开
- ios之自动拾取器
- 什么叫大数据?世界地图告诉你!
- Uiview的拖拽