gpt4 book ai didi

android - 从 Materialdrawer 中删除左边距

转载 作者:行者123 更新时间:2023-11-29 15:43:15 26 4
gpt4 key购买 nike

如何删除 Mikepenz Material Drawer 空间。我为配置文件菜单和抽屉项目使用了自定义布局。我没有为这些 View 设置边距或填充。我还尝试将 Activity 水平边距设置为 0。enter image description here帮助将不胜感激。同样的 margin 右侧也。配置文件菜单正常。它没有问题。而 draweritem 面临问题。

下面的代码是配置文件菜单

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imgUserProfileImage"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="@dimen/min_margin"
android:src="@drawable/parent" />

<com.CustomTextView

android:id="@+id/txtUserName"

style="@style/label_text_primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
android:text="Noorul"
app:font="@string/montserrat_semi_bold" />
</LinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="0.3dp"
android:layout_marginTop="@dimen/min_margin"
android:layout_marginLeft="@dimen/min_margin"
android:background="#999999" />
</LinearLayout>


</LinearLayout>

下面的代码用于抽屉项目菜单

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/lnrSecond_menu"
android:layout_width="match_parent"
android:layout_height="@dimen/material_drawer_item_secondary"
android:orientation="horizontal">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">

<View
android:id="@+id/view"
android:layout_width="3dp"
android:layout_height="match_parent"
android:background="@color/primary"
android:visibility="gone"/>

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center">

<ImageView
android:id="@+id/material_drawer_icon"
android:layout_width="@dimen/profile_img"
android:layout_height="@dimen/profile_img"
android:padding="@dimen/most_most_normal_margin"
android:src="@mipmap/ic_launcher" />
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical|start"
android:orientation="vertical">

<com.CustomTextView
android:id="@+id/material_drawer_name"
style="@style/label_text_secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|start"
android:textDirection="anyRtl"
android:text="Some Secondary Text"
app:font="@string/montserrat_regular"
/>

<com.CustomTextView
android:id="@+id/material_drawer_description"
style="@style/label_text_secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:visibility="gone"
app:font="@string/montserrat_regular"
android:text="Some drawer text" />
</LinearLayout>

<LinearLayout
android:id="@+id/material_drawer_badge_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="right|center">

<com.CustomTextView
android:id="@+id/txtMenuBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/min_margin"
android:gravity="center"
android:text="99" />
</LinearLayout>

</LinearLayout>

我在哪里犯了错误?帮助我,我将不胜感激。

最佳答案

抽屉添加此 padding 因为它是 Material Design Guidelines 中所有项目的默认设置。由于 API 17 存在问题,因此我必须在此行中以编程方式进行设置: https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/model/BasePrimaryDrawerItem.java#L104

您可能还想发布您使用的 DrawerItem,因为屏幕截图看起来不像您使用的是默认项目。

如果您已经创建了自己的 CustomDrawerItem,您只想再次将填充设置为 0px(如果您从 BasePrimaryDrawerItem 扩展)如果您不从它扩展,您应该没事。

抽屉不会在除此处以外的任何地方的项目上设置此填充。

关于android - 从 Materialdrawer 中删除左边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37168281/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com