drawlayout(二)
来源:互联网 发布:阿里云 windows vpn 编辑:程序博客网 时间:2024/05/22 17:41
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="切换" /> <android.support.v4.widget.DrawerLayout android:id="@+id/drawerlayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/ic_launcher" > <LinearLayout android:id="@+id/lin_center" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#1111E7" > </LinearLayout> <LinearLayout android:id="@+id/lin_left" android:layout_width="250dp" android:layout_height="match_parent" android:orientation="vertical" android:layout_gravity="start" android:background="#63F138"> </LinearLayout> <LinearLayout android:id="@+id/lin_right" android:layout_width="250dp" android:layout_height="match_parent" android:orientation="vertical" android:layout_gravity="end" android:background="#F30F37"> </LinearLayout> </android.support.v4.widget.DrawerLayout></LinearLayout>
public class MainActivity extends Activity implements OnClickListener { private DrawerLayout drawerLayout; private Button button; private LinearLayout lin_center, lin_left, lin_right; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Utils_log.d1("myTag", "onCreate1111"); drawerLayout = (DrawerLayout) findViewById(R.id.drawerlayout); lin_center = (LinearLayout) findViewById(R.id.lin_center); lin_left = (LinearLayout) findViewById(R.id.lin_left); lin_right = (LinearLayout) findViewById(R.id.lin_right); button = (Button) findViewById(R.id.button1); button.setOnClickListener(MainActivity.this); // 监听抽屉的事件 drawerLayout.setDrawerListener(new DrawerListener() { /** * 当抽屉的状态发生改变是回调 滑动中:1 滑动结束:2 恢复闲置:0 * */ public void onDrawerStateChanged(int arg0) { } /** * 滑动的百分比:滑动的距离是0-1 * */ public void onDrawerSlide(View arg0, float arg1) { if (arg0 == lin_left) {// 如果滑动的是左侧的抽屉 // 将中间的抽屉向右移动 lin_center.setX(200 * (arg1 * 100.0f) / 100.0f); // 创建缩放动画 float fromX = 1.0f; float toX = 1- (arg1*0.4f); float fromY = 1.0f; ScaleAnimation scaleAnimation = new ScaleAnimation(fromX, toX, fromY, toX, Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0.5f); scaleAnimation.setFillAfter(true); scaleAnimation.setDuration(2); fromX = toX; fromY = toX; lin_center.startAnimation(scaleAnimation); } } @Override public void onDrawerOpened(View arg0) { } @Override public void onDrawerClosed(View arg0) { } }); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.button1: if (drawerLayout.isDrawerOpen(Gravity.LEFT) || drawerLayout.isDrawerOpen(Gravity.RIGHT)) { drawerLayout.closeDrawers(); } else { drawerLayout.openDrawer(Gravity.LEFT); } break; default: break; } }}
0 0
- drawlayout(二)
- 抽屉效果(DrawLayout)
- DrawLayout
- DrawLayout
- Drawlayout
- DrawLayout
- drawlayout
- 王学岗ToolBar,DrawLayout+Navigation的使用(二)
- 侧滑菜单(三):DrawLayout
- DrawLayout的全屏滑动(取消长按效果)
- drawlayout侧滑
- 初学Android之viewPager+imageLoader+图片圆角(类似qq头像)+xListView+DrawLayout
- DrawLayout的使用
- drawlayout的使用
- DrawLayout 侧滑侧栏点击穿透
- drawlayout的使用
- Drawlayout 抽屉 禁用滑动
- DrawLayout侧拉
- STM32生态圈,STM32CubeMX真是好工具
- get和post
- 【转】PHP SQL防注入的一些经验
- codeforces-gym-100187-D【组合数】【逆元】
- 解析带有转义字符的json
- drawlayout(二)
- Android-AsyncHttpClient网络框架
- 51Nod-1158-全是1的最大子矩阵
- UE4蓝图中的AI行为树功能使用经验指南
- 为什么说ucos ii是可剥夺的内核。
- POCO C++例程整理--有关线程
- 04.Mybatis初级使用-Mapper映射器(一)
- inputstream outputstrteam
- Qt5发布程序