[android]代码库
。、、、、、、、、、、布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bwie.testdemo3.MainActivity">
<android.support.v4.widget.SlidingPaneLayout
android:id="@+id/slidepanel"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include
android:id="@+id/menu"
layout="@layout/menu_layout" />
<include
android:id="@+id/content"
layout="@layout/content_layout" />
</android.support.v4.widget.SlidingPaneLayout>
</RelativeLayout>
、、、、、、、、、、、主界面
import android.support.v4.widget.SlidingPaneLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
public class MainActivity extends AppCompatActivity implements SlidingPaneLayout.PanelSlideListener {
private SlidingPaneLayout paneLayout = null;
private static final String TAG = "ZiHao";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
/**
* 初始化视图
*/
private void initView() {
paneLayout = (SlidingPaneLayout) findViewById(R.id.slidepanel);
paneLayout.setPanelSlideListener(this);
}
/**
* 面板完全关闭回调
*/
@Override
public void onPanelClosed(View view) {
// TODO Auto-generated method stub
Log.d(TAG, "菜单已关闭");
}
/**
* 面板完全打开回调
*/
@Override
public void onPanelOpened(View view) {
// TODO Auto-generated method stub
Log.d(TAG, "菜单已打开");
}
/**
* 面板发生改变时的回调--滑动过程中持续回调
*/
@Override
public void onPanelSlide(View view, float slideOffset) {
// TODO Auto-generated method stub
Log.d(TAG, "界面视图发生改变...");
}
}