用户界面 View(九)(转载)

本讲内容:SlidingDrawer 抽屉类
今天我们一起学习看起来很炫、功能很强、又容易学会的抽屉类。
先用一个最简单的例子来入门。
一、实例 HelloSildingDrawer
1、新建一个项目 Lesson42_HelloSlidingDrawer
2、在Eclipse中打开main.xml,在Graphical Layout 视图里,拖拽SlidingDrawer 这个组件出来。
1.jpg
2011-4-29 16:10 上传
下载附件 (66.44 KB)



切换到文本方式,在SlidingDrawer标签中增加一行 android: orientation="horizontal" 给内容区添加一个背景色,以便确认,具体内容如下:



  1. <?xml version="1.0" encoding="utf-8"?>
  2. <linearlayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
  3.         <textview android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="欢迎进入最简单的抽屉类实例">
  4.         <slidingdrawer android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="horizontal" android:id="@+id/slidingDrawer1" android:handle="@+id/handle" android:content="@+id/content">
  5.                 <button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/handle" android:text="Handle">
  6.                 </button>
  7. <linearlayout android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/content">
  8.                 </linearlayout>
  9.         </slidingdrawer>
  10. </textview></linearlayout>
复制代码

3、其他地方不需要做任何更改,直接编译运行程序,查看一下结果:2.png 
点击按钮,可以看到动画过后,拉出了一个抽屉容器:
3.png 
如果我们不改方向属性的话,它默认是从下向上拉出抽屉的。二、实例:制作应用程序列表抽屉我们接下来用一个复杂点的实例,来学习SlidingDrawer的属性和方法。

转自:http://www.apkbus.com/android-1127-1-1.html

转载于:https://www.cnblogs.com/jyan/articles/2536915.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值