【问题标题】:Drawer android, remove arrow抽屉android,删除箭头
【发布时间】:2015-09-23 17:14:53
【问题描述】:

我的应用程序中有抽屉,我使用这个库:com.mikepenz:materialdrawer 当我制作抽屉时,我有一个箭头,我该如何移除它?以及如何在抽屉中制作个人资料的圆形图像?


就是这样:

这是我的抽屉代码:

AccountHeader headerResult = new AccountHeaderBuilder()
    .withActivity(activity)
    .withHeaderBackground(R.drawable.header)
    .addProfiles(
        new ProfileDrawerItem().withName(activity.getResources().getString(R.string.nickname))
        .withEmail(activity.getResources().getString(R.string.drawer_second_line))
        .withIcon(activity.getResources().getDrawable(R.drawable.schooler)))
    .build();

Drawer result = new DrawerBuilder()
    .withAccountHeader(headerResult)
    .withActivity(activity)
    .withToolbar(toolbar)
    .withTranslucentStatusBar(false)
    .withActionBarDrawerToggle(true)
    .addDrawerItems(
        new PrimaryDrawerItem().withName(R.string.drawer_item_card).withIcon(FontAwesome.Icon.faw_credit_card).withIdentifier(1),
        new PrimaryDrawerItem().withName(R.string.drawer_item_pay).withIcon(FontAwesome.Icon.faw_money),
        new PrimaryDrawerItem().withName(R.string.drawer_item_lock).withIcon(FontAwesome.Icon.faw_lock).withIdentifier(2),
        new DividerDrawerItem(),
        new SecondaryDrawerItem().withName(R.string.drawer_item_journal).withIcon(FontAwesome.Icon.faw_book),
        new SecondaryDrawerItem().withName(R.string.drawer_item_homework).withIcon(FontAwesome.Icon.faw_calendar),
        new SecondaryDrawerItem().withName(R.string.drawer_item_food).withIcon(FontAwesome.Icon.faw_cutlery),
        new SecondaryDrawerItem().withName(R.string.drawer_item_contact).withIcon(FontAwesome.Icon.faw_comment).withIdentifier(1),
        new DividerDrawerItem(),
        new SecondaryDrawerItem().withName(R.string.drawer_item_friends).withIcon(FontAwesome.Icon.faw_users),
        new SecondaryDrawerItem().withName(R.string.drawer_item_settings).withIcon(FontAwesome.Icon.faw_cog),
        new SecondaryDrawerItem().withName(R.string.drawer_item_help).withIcon(FontAwesome.Icon.faw_question_circle))
    .build();

【问题讨论】:

    标签: android navigation-drawer material-design


    【解决方案1】:

    移除箭头是一项非常简单的任务。只需通过以下方法禁用它:

    withSelectionListEnabledForSingleProfile(false)
    

    https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/AccountHeaderBuilder.java#L545

    抽屉将方形图像作为Profile图像。如果您想禁用圆形遮罩,您可以简单地定义使用的不同遮罩。只需覆盖样式:

    <style name="BezelImageView">
        <item name="biv_maskDrawable">@drawable/material_drawer_square_mask</item>
        <item name="biv_drawCircularShadow">false</item>
        <item name="biv_selectorOnPress">@color/material_drawer_primary</item>
    </style>
    

    https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/res/values/styles.xml#L28

    【讨论】:

    • withSelectionListEnabledForSingleProfile(false) 是我需要的
    【解决方案2】:

    您需要获取源并将其添加到您的项目中,然后四处挖掘并找到此抽屉正在使用的布局并进行修改。

    【讨论】:

    • 库的源文件
    【解决方案3】:

    猫头鹰的回答完全没有帮助。

    您可以做的是在构建抽屉标题时调用 withSelectionListEnabled(false),这将完全符合您的要求。

    示例代码:

    AccountHeader drawerHeader = new AccountHeaderBuilder()
                .withActivity(this).withSelectionListEnabled(false)
                .withHeaderBackground(R.drawable.drawerheader)
                .addProfiles(
                        new ProfileDrawerItem().withName("Mike Penz").withEmail("mikepenz@gmail.com")
                )
                .build();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多