侧拉drawlayout/slidingmenu

布局

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/draw"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#000000"
            android:orientation="horizontal">
            <Button
                android:id="@+id/btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="left"
            android:background="#ded3d3"
            android:orientation="horizontal">
            <Button
                android:id="@+id/btn2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#000000"/>
        </LinearLayout>
    </android.support.v4.widget.DrawerLayout>
</LinearLayout>

主页面

DrawerLayout drawerLayout = (DrawerLayout) findViewById (R.id.draw);
drawerLayout.openDrawer (Gravity.LEFT);
drawerLayout.closeDrawer (Gravity.LEFT);

打印一个Log

drawerLayout.addDrawerListener (new DrawerLayout.DrawerListener () {
            @Override
            public void onDrawerSlide(@NonNull View view, float v) {

            }

            @Override
            public void onDrawerOpened(@NonNull View view) {
                 Log.e ("wyy","侧拉菜单打开了");
            }

            @Override
            public void onDrawerClosed(@NonNull View view) {
                Log.e ("wyy","侧拉菜单关闭了");
            }

            @Override
            public void onDrawerStateChanged(int i) {
                Log.e ("wyy","侧拉菜单状态改变了");
            }
        });
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WPF实现侧拉式菜单栏可以通过以下步骤实现: 1.创建一个具有侧拉式菜单栏的主窗口 2.在主窗口中添加一个侧拉式菜单栏控件,并设置其大小和位置 3.在侧拉式菜单栏控件中添加需要显示的菜单项,并设置其大小、位置和相关事件处理程序 4.在主窗口中添加一个主内容区域控件,并设置其大小和位置 5.在主内容区域控件中添加需要显示的内容,并设置其大小、位置和相关事件处理程序 代码示例: ``` <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Border Grid.Column="0" Background="Gray" Width="150" VerticalAlignment="Stretch"> <StackPanel> <Button Content="Menu Item 1" Margin="10"/> <Button Content="Menu Item 2" Margin="10"/> <Button Content="Menu Item 3" Margin="10"/> </StackPanel> </Border> <Border Grid.Column="1" Background="White" Margin="10"> <TextBlock Text="Main Content Area" Margin="10"/> </Border> </Grid> </Window> ``` 在上面的示例中,我们使用Grid布局来实现侧拉式菜单栏和主内容区域的布局,同时使用Border控件来包裹菜单项和主内容。在侧拉式菜单栏中,我们使用StackPanel来布局菜单项,并在每个菜单项上添加了Margin属性来设置间距。在主内容区域中,我们使用TextBlock控件来显示内容。 需要注意的是,上述示例仅供参考,您可以根据自己的实际需要进行修改和完善。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值