原文出处: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其它新控件 (转)的更多相关文章

  1. 【转】Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用

    Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用 分类: Android UI ...

  2. 【转】Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用

    Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用 分类: Android UI2015-06-15 16: ...

  3. android design 新控件

    转载请标明出处: http://blog.csdn.net/forezp/article/details/51873137 本文出自方志朋的博客 最近在研究android 开发的新控件,包括drawe ...

  4. [转 载] android 谷歌 新控件(约束控件 )ConstraintLayout 扁平化布局

    序 在Google IO大会中不仅仅带来了Android Studio 2.2预览版,同时带给我们一个依赖约束的库. 简单来说,她是相对布局的升级版本,但是区别与相对布局更加强调约束.何为约束,即控件 ...

  5. Android L新控件RecyclerView简介

    Android L是android进化史上的里程碑,尽管还没有正式发布4.5或者5.0,但预览版也同样精彩. 这篇文章只是另外一篇博客的总结性翻译,能够读懂原文的,可以点开这个链接去阅读精彩的原文:h ...

  6. android L 新控件侧滑菜单DrawerLayout 使用教程

    介绍 drawerLayout是Support Library包中实现了侧滑菜单效果的控件,可以说drawerLayout是因为第三方控件如MenuDrawer等的出现之后,google借鉴而出现的产 ...

  7. android L新控件RecyclerView详解与DeMo[转]

    http://blog.csdn.net/codebob/article/details/37813801 在谷歌的官网我们可以看到它是这样介绍的: RecyclerView  is a more a ...

  8. android L新控件RecyclerView具体解释DeMo

    简介 在谷歌的官方网站上,我们可以看到,它是此演示文稿:RecyclerView is a more advanced and flexible version of ListView. This w ...

  9. 【Android】Anroid5.0+新控件---酷炫标题栏的简单学习

    Android5.0+推出的新控件感觉特别酷,最近想模仿大神做个看图App出来,所以先把这些新控件用熟悉了. 新控件的介绍.使用等等网上相应的文章已经特别多了,题主也没那能力去写篇详解出来,本篇随笔记 ...

随机推荐

  1. MyBatis使用总结+整合Spring

    MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis .20 ...

  2. UVA 11800 Determine the Shape --凸包第一题

    题意: 给四个点,判断四边形的形状.可能是正方形,矩形,菱形,平行四边形,梯形或普通四边形. 解法: 开始还在纠结怎么将四个点按序排好,如果直接处理的话,有点麻烦,原来凸包就可搞,直接求个凸包,然后点 ...

  3. CF687C. The Values You Can Make[背包DP]

    C. The Values You Can Make time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  4. C#手工注入辅助工具

    看了某牛出版的MySql手注天书一神书,基本上解决了SQL注入上的知识点,于是打完(酱油)省赛回来通宵了一晚上写了个工具 方便语句构造SQL 联合查询 报错注入 盲注 读写 命令执行 基本都有整合 遇 ...

  5. MySQL日志管理

    MySQL日志管理 2013年09月26日 ⁄ MySQL ⁄ 共 14266字 ⁄ 评论数 ⁄ 被围观 , views+ 一.日志类型: MySQL有几个不同的日志文件,可以帮助你找出mysqld内 ...

  6. github上写blog

    http://www.elbow95.me/blog/My-First-Blog-Essay.html 阮一峰的: http://www.ruanyifeng.com/blog/2012/08/blo ...

  7. PAT 1021. 个位数统计 (15)

    给定一个k位整数N = dk-1*10k-1 + ... + d1*101 + d0 (0<=di<=9, i=0,...,k-1, dk-1>0),请编写程序统计每种不同的个位数字 ...

  8. SQL server 数据库备份还原Sql

    /************ 一.数据库备份 ************/ --完整备份默认追加到现有的文件 backup database DBXS To disk='d:\backup\DBXS_fu ...

  9. RelayCommand

    RelayCommand Mvvm最大的特点就是分离了View和ViewModel,将数据的显示和业务逻辑分开.使用WPF的Binding,我们不仅能够 将数据从ViewModel绑定到View,同时 ...

  10. SM2国密证书合法性验证

    通常我们遇到过的X509证书都是基于RSA-SHA1算法的,目前国家在大力推行国密算法,未来银行发行的IC卡也都是基于PBOC3.0支持国密算法的,因此我们来学习一下如何验证SM2国密证书的合法性.至 ...