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() {
@Overridepublic void onRefresh() {
Log.i("SwipeRefreshLayout","下拉刷新");
//do something,刷新视图内容
refresh.setRefreshing(false);//设置刷新结束
Log.i("SwipeRefreshLayout","刷新完毕");
}
});
本程序源代码下载:Android其它新控件
Android其它新控件 (转)的更多相关文章
- 【转】Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用
Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用 分类: Android UI ...
- 【转】Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用
Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用 分类: Android UI2015-06-15 16: ...
- android design 新控件
转载请标明出处: http://blog.csdn.net/forezp/article/details/51873137 本文出自方志朋的博客 最近在研究android 开发的新控件,包括drawe ...
- [转 载] android 谷歌 新控件(约束控件 )ConstraintLayout 扁平化布局
序 在Google IO大会中不仅仅带来了Android Studio 2.2预览版,同时带给我们一个依赖约束的库. 简单来说,她是相对布局的升级版本,但是区别与相对布局更加强调约束.何为约束,即控件 ...
- Android L新控件RecyclerView简介
Android L是android进化史上的里程碑,尽管还没有正式发布4.5或者5.0,但预览版也同样精彩. 这篇文章只是另外一篇博客的总结性翻译,能够读懂原文的,可以点开这个链接去阅读精彩的原文:h ...
- android L 新控件侧滑菜单DrawerLayout 使用教程
介绍 drawerLayout是Support Library包中实现了侧滑菜单效果的控件,可以说drawerLayout是因为第三方控件如MenuDrawer等的出现之后,google借鉴而出现的产 ...
- android L新控件RecyclerView详解与DeMo[转]
http://blog.csdn.net/codebob/article/details/37813801 在谷歌的官网我们可以看到它是这样介绍的: RecyclerView is a more a ...
- android L新控件RecyclerView具体解释DeMo
简介 在谷歌的官方网站上,我们可以看到,它是此演示文稿:RecyclerView is a more advanced and flexible version of ListView. This w ...
- 【Android】Anroid5.0+新控件---酷炫标题栏的简单学习
Android5.0+推出的新控件感觉特别酷,最近想模仿大神做个看图App出来,所以先把这些新控件用熟悉了. 新控件的介绍.使用等等网上相应的文章已经特别多了,题主也没那能力去写篇详解出来,本篇随笔记 ...
随机推荐
- 设置SecureCRT配色和解决乱码问题
SecureCRT是一款支持SSH(SSH1和SSH2)的终端仿真程序,简单的说是Windows下登录UNIX或Linux服务器主机的软件. 一.配色 第一步: Options => Sessi ...
- c++整型->字符型转换
有itoa(),atoi(),sprintf()三个函数 使用字符串流: #include<iostream> #include<string> #include<sst ...
- JAVA面向对象之一
一.面向过程的思想和面向对象的思想 面向对象和面向过程的思想有着本质上的区别, 作为面向对象的思维来说,当你拿到一个问题时,你分析这个问题不再是第一步先做什么,第二步再做什么,这是面向过程的思维,你应 ...
- linux 防火墙开启80端口永久保存
经常使用CentOS的朋友,可能会遇到和我一样的问题.开启了防火墙导致80端口无法访问,刚开始学习centos的朋友可以参考下.经常使用CentOS的朋友,可能会遇到和我一样的问题.最近在Linux ...
- zlog学习笔记(zc_hashtable)
zc_hashtable.h /** * hashtable */ #ifndef __zc_hashtable_h #define __zc_hashtable_h typedef struct z ...
- css实现省略号
样式: {width: 160px; overflow: hidden; text-overflow:ellipsis; white-space: nowrap;} 说明: white-space: ...
- js函数命名常用动词
get 获取/set 设置, add 增加/remove 删除 create 创建/destory 移除 start 启动/stop 停止 open 打开/close 关闭, read 读取/writ ...
- PAT 1003. 我要通过!(20)
"答案正确"是自动判题系统给出的最令人欢喜的回复.本题属于PAT的"答案正确"大派送 -- 只要读入的字符串满足下列条件,系统就输出"答案正确&quo ...
- npm淘宝镜像
前端开发会用到npm的包,但是国外的速度有时候很慢,幸运的是,淘宝做了镜像,一起来看看吧. https://npm.taobao.org/
- MongoDB JAVA API Filters
Filters 该过滤器类为所有的MongoDB的查询操作静态工厂方法.每个方法返回BSON类型,又可以传递给期望一个查询过滤器的任何方法的一个实例. eq:匹配等于指定值的值.gt:匹配大于指定值的 ...