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出来,所以先把这些新控件用熟悉了. 新控件的介绍.使用等等网上相应的文章已经特别多了,题主也没那能力去写篇详解出来,本篇随笔记 ...
随机推荐
- 第四章 分治策略 4.2 矩阵乘法的Strassen算法
package chap04_Divide_And_Conquer; import static org.junit.Assert.*; import java.util.Arrays; import ...
- MordenPHP阅读笔记(一)——先跑再说,跑累了再走
---恢复内容开始--- 后台一大堆半成品,或者是几乎不成的... 这本书不错,起码是别人推荐的,然后也是比较新的东西,学哪本不是学嘛,关键是得看. 今儿个网不好,科研所需的代码下不到,看书做笔记吧. ...
- Openxml入门---Openxm读取Excel数据
Openxml读取Excel数据: 有些问题,如果当Cell 里面是 日期和浮点型的话,对应的Cell.DataType==Null,对应的时间会转换为一个浮点型,对于这块可以通过DateTime.F ...
- [cocos2d-x]深入--几个代表性的类
摘要: 此文对cocos2d-x引擎中最具代表性,最能体现框架结构的几个类做了简单的介绍, 包括Director,Application, Renderer, EventDispatcher, Sch ...
- BZOJ2118墨墨的等式[数论 最短路建模]
2118: 墨墨的等式 Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 1317 Solved: 504[Submit][Status][Discus ...
- NOIP2000进制转换
题目描述 我们可以用这样的方式来表示一个十进制数: 将每个阿拉伯数字乘以一个以该数字所处位置的(值减1)为指数,以10为底数的幂之和的形式.例如:123可表示为 1*10^2+2*10^1+3*10^ ...
- IT菜鸟的第一天
小弟愚钝,被别人影响,打算入IT行业试试水的深浅,俗话说技不压身,多会一种就多一条路子,抱着这种求知的心态我就开始的我在汉企的IT生涯! 第一天无非就是简介,对IT行业的介绍,反正听得我挺懵的,不过介 ...
- 移植SDL运行库到Tiny6410 上
在移植游戏之前, 我们首先需要将 SDL/SDL_mixer/SDL_ttf/SDL_image 这四个库移植到 Tiny6410 上, 另外还需要 iconv 库. libiconv-1.13.1. ...
- http协议(七)通用首部字段
通用首部字段的意思,就是:请求和响应报文双方都会使用的首部 1.Cache-Control 通过指定它的指令,能操作缓存的工作机制 指令参数是可选的,多个指令通过“,”分隔 Cache-Control ...
- Mysql优化系列(1)--Innodb引擎下mysql自身配置优化
1.简单介绍InnoDB给MySQL提供了具有提交,回滚和崩溃恢复能力的事务安全(ACID兼容)存储引擎.InnoDB锁定在行级并且也在SELECT语句提供一个Oracle风格一致的非锁定读.这些特色 ...