首先看下android 的API

Class Overview

SlidingDrawer hides content out of the screen and allows the user to drag a handle to bring the content on screen. SlidingDrawer can be used vertically or horizontally. A special widget composed of two children views: the handle, that the users drags, and the content, attached to the handle and dragged with it. SlidingDrawer should be used as an overlay inside layouts. This means SlidingDrawer should only be used inside of a FrameLayout or a RelativeLayout for instance. The size of the SlidingDrawer defines how much space the content will occupy once slid out so SlidingDrawer should usually use match_parent for both its dimensions. Inside an XML layout, SlidingDrawer must define the id of the handle and of the content:

 <SlidingDrawer      android:id="@+id/drawer"      android:layout_width="match_parent"      android:layout_height="match_parent"      android:handle="@+id/handle"      android:content="@+id/content">      <ImageView          android:id="@id/handle"          android:layout_width="88dip"          android:layout_height="44dip" />      <GridView          android:id="@id/content"          android:layout_width="match_parent"          android:layout_height="match_parent" />  </SlidingDrawer>  

以下部分内容参考来自:http://blog.csdn.net/wangkuifeng0118/article/details/7229200

然后我写的layout如下:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <SlidingDrawer         android:id="@+id/slidingdraw"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:handle="@+id/handle"        android:content="@+id/content"        >        <ListView             android:id="@id/content"            android:layout_width="match_parent"            android:layout_height="match_parent"            />               <ImageView android:id="@id/handle"            android:src="@drawable/drawer_open"            android:layout_width="88dip"            android:layout_height="44dip"             android:contentDescription="TODO"/>    </SlidingDrawer></LinearLayout>

整个Activity代码如下 :

package ditouch.client.guilin;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import android.app.Activity;import android.os.Bundle;import android.widget.ImageView;import android.widget.ListView;import android.widget.SimpleAdapter;import android.widget.SlidingDrawer;public class SlidingDrawerActivity extends Activity {private SlidingDrawer mDrawer;private ImageView mImageView;private ListView mListView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.slidedraw_test);mDrawer = (SlidingDrawer) findViewById(R.id.slidingdraw);mImageView = (ImageView) findViewById(R.id.handle);mListView = (ListView) findViewById(R.id.content);String[] ids = { "1", "2", "3" };String[] titles = { "a", "b", "c" };List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();;HashMap<String, Object> map = new HashMap<String, Object>();for (int i = 0; i < ids.length; i++) {map.put("ids", ids[i]);map.put("title", titles[i]);list.add(map);}SimpleAdapter adapter = new SimpleAdapter(this, list,R.layout.ordered_item, new String[] { "ids", "title" },new int[] { R.id.ids, R.id.title });mListView.setAdapter(adapter);mDrawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {@Overridepublic void onDrawerOpened() {mImageView.setImageResource(R.drawable.drawer_close);}});mDrawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {@Overridepublic void onDrawerClosed() {mImageView.setImageResource(R.drawable.drawer_open);}});}}

大概就是上面 的了。哈哈。

上面内容参考:http://my.oschina.net/chen106106/blog/49041

2. 上面的一个重大的问题就是,默认不是上向下拉的。而android的状态栏默认是从上向下拉的。

你用中文搜索的时候发现得最多的解决方案是:使用Panel

这个类的地址在:

http://code.google.com/p/android-misc-widgets/source/browse/trunk/android-misc-widgets/src/org/miscwidgets/widget/Panel.java

介绍的文章我看到最初来自:http://blog.csdn.net/hellogv/article/details/6789698

然后使用这个类我是我想要的,然后就用英文搜索:Slidingdrawer drop from top to bottom

第一条根据android的SlidingDrawer改写widget。哈哈,就是我想要的。

http://blog.sephiroth.it/2011/03/29/widget-slidingdrawer-top-to-bottom/



更多相关文章

  1. Android 面试题及答案(英文)
  2. 动画:散列表 | 文本编辑器是如何检查英文单词出错的?
  3. PHP如何将中文转英文
  4. 英文都不懂.碰都没碰过编程软件!是心理的好奇心感觉未来的发展趋
  5. python1.返回一个字符串中出现次数第二多的单词 2.字符串中可能
  6. Python 英文词频统计
  7. 《LINUX SHELL脚本攻略》(Sarath Lakshman中文版带书签) 和 英文
  8. Linux 常用命令使用英文全称
  9. ubuntu (16.04) server 英文原版 添加中文语言支持 消除java 程

随机推荐

  1. Android(安卓)ViewPager
  2. android实现自己的浏览器
  3. android fw systemserver之MountService
  4. 安卓项目常规设置清单
  5. Android(安卓)WindowManager 小结
  6. Android(安卓)studio 使用github上的andr
  7. Android之Activity相关
  8. android有效解决加载大图片内存溢出的问
  9. Android(安卓)X86 Android-x86入门之--让
  10. Android(安卓)智能问答机器人的实现