MainActivity.xml
package cn.hy.sliddrawer;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.SlidingDrawer;
public class MainActivity extends Activity {
private SlidingDrawer mDialerDrawer;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mDialerDrawer = (SlidingDrawer) findViewById(R.id.slidingdrawer);
mDialerDrawer.setOnDrawerScrollListener(new SlidingDrawer.OnDrawerScrollListener() {
@Override
public void onScrollStarted() {
Log.i("android", "onScrollStarted()");
}
@Override
public void onScrollEnded() {
Log.i("android", "onScrollEnded()");
}
});
mDialerDrawer.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
Log.i("android", "onDrawerOpened()");
}
});
mDialerDrawer.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
Log.i("android", "onDrawerClosed()");
}
});
}
}
hanle.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false"
android:state_enabled="true"
android:drawable="@drawable/handle_normal" />
<item android:state_pressed="true"
android:drawable="@drawable/handle_pressed" />
<item android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/handle_selected"/>
<item android:state_enabled="true"
android:drawable="@drawable/handle_normal" />
<item android:state_focused="true"
android:drawable="@drawable/handle_selected" />
</selector>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#808080">
<SlidingDrawer
android:id="@+id/slidingdrawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:handle="@+id/handle"
android:content="@+id/content">
<Button
android:id="@+id/handle"
android:layout_width="88dip"
android:layout_height="44dip"
android:background="@drawable/handle"/>
<!--
<LinearLayout
android:id="@+id/handle"
android:layout_width="88dip"
android:layout_height="44dip"
android:background="#0000FF"/>
-->
<LinearLayout
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00FF00">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>
<EditText
android:id="@+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
- 大小: 30.5 KB
- 大小: 203 Bytes
- 大小: 204 Bytes
- 大小: 206 Bytes
分享到:
相关推荐
android slidingdrawer实例
android SlidingDrawer 可以从上下左右四个方向拉出,只需要更改main.xml中的my:direction方向即可
实用的 Android SlidingDrawer抽屉效果
网络上关于slidingdrawer我资料不太完整,都是1.5的包。在现在不能用。此资源已经转成2.2版本的。有兴趣可以下一下。
这个范例非常非常非常的好,实现了从屏幕的任何方向拉出抽屉,值得借鉴……
用SlidingDrawer注意两点,一个是android:handle(委托要展开的图片加载Layout配置) 和android:content(要展开的Layout Content), 我的csdn博客地址: ...
知识共享-android之slidingdrawer的应用(雷惊风).
一个Android滑动抽屉,上滑打开,滑下来关闭,也有自动倒带。 支持正常布局,Listview,ScrollView,RecyclerView。
Android学习笔记(二四):多页显示SlidingDrawer的使用
本篇文章小编为大家介绍,Android SlidingDrawer 抽屉效果的实现。需要的朋友参考下
默认显示抽屉的一部分,屏幕分上下二部分;通过打开按钮实现,抽屉的下面部分打开和关闭,同时上面部分自动伸展。
Android SlidingDrawer
Android自带SlidingDrawer实例,即只能从下往上拖动,供初学者参考。
这是我自己编写的一个android 的slidingdrawer应用 效果还可以 希望可以帮助到刚刚学习android的朋友
这是一款不错的安卓SlidingDrawer抽屉控件案例,该案例的演示也很简单的,而且源码也很容易看得懂,非常适合一些新手的使用与学习,大家不妨去看看吧。
SlidingDrawer抽屉式滑动效果
Android SlidingDrawer控件的使用。开发环境Android studio3.0版本
Android Launcher抽屉类SlidingDrawer的使用