android - 当我增加图标大小时,侧边栏菜单图标被修剪
问题描述
我想要一个只有图标的侧边栏菜单,所以我想增加图标大小以使其更明显,通过放置它来增加图标大小Demens.xml
:
<dimen name="design_navigation_icon_size"
tools:override="true">72dp</dimen>
这是我的菜单文件:
<?xml version="1.0" encoding="utf-8"?>
<item android:id="@+id/menu_item_start_new_trip"
android:icon="@drawable/ic_menu_start_new_trip"
/>
<item android:id="@+id/menu_item_edit_current_trip"
android:icon="@drawable/ic_menu_icon_edit_trip"
/>
<item android:id="@+id/menu_item_saved_trip"
android:icon="@drawable/ic_menu_saved_trip"
/>
<item android:id="@+id/menu_item_about"
android:icon="@drawable/ic_question_mak"
/>
</group>
这是我的抽屉布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout_home_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start"
android:fitsSystemWindows="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@+id/map"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=".HomeMapActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintVertical_bias="0.0"/>
<include
android:id="@+id/tbHomeMap"
layout="@layout/toolbar_home_map" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="1.0"/>
<androidx.constraintlayout.widget.Guideline android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/guideline16"
android:orientation="horizontal" app:layout_constraintGuide_end="32dp"/>
<androidx.constraintlayout.widget.Guideline android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/guideline17"
android:orientation="vertical" app:layout_constraintGuide_end="16dp"/>
<androidx.constraintlayout.widget.Guideline android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/guideline18"
android:orientation="vertical"
app:layout_constraintGuide_begin="16dp"/>
<ImageButton
android:id="@+id/btnHomeIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_home_page"
android:background="@null"
app:layout_constraintEnd_toStartOf="@+id/guideline17"
app:layout_constraintBottom_toTopOf="@+id/guideline16"/>
<Button
android:paddingEnd="10sp"
android:layout_height="0dp"
android:text="@string/btnStartNewTrip"
android:drawableRight="@drawable/ic_start_new_trip"
android:textSize="@dimen/text_size"
android:textAllCaps="false"
android:background="@drawable/button_baground_blue_no_edge" android:id="@+id/btnStartNewTrip"
app:layout_constraintTop_toTopOf="@+id/btnHomeIcon"
app:layout_constraintBottom_toBottomOf="@+id/btnHomeIcon"
app:layout_constraintStart_toStartOf="@+id/guideline18"
app:layout_constraintEnd_toStartOf="@+id/btnHomeIcon"
android:layout_width="0dp" android:layout_marginEnd="8dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize"
android:layout_gravity="start"
android:background="@android:color/transparent"
app:menu="@menu/side_bar_navigation_menu"
android:fitsSystemWindows="true"
/>
</androidx.drawerlayout.widget.DrawerLayout>
这是图标被修剪时的图像:
解决方案
谢谢,但我设法在这里找到了解决方案:
在 style.xml 中:
resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
.
.
.
<item name="listPreferredItemHeightSmall">80dp</item>
</style>
推荐阅读
- vue.js - 在所有浏览器的 VueJS PWA 上锁定方向(纵向)
- c++ - Rcpp::sourceCpp() 中的错误:构建共享库时发生错误 1
- r - 从 4000 多个图像集中过滤出 4 个完整的组
- laravel-5.7 - 如何解决 laravel 中的“__construct() 必须是实例”错误?
- css - 移动菜单不会以 Astra WordPress 主题为中心。请指教?
- linux - 从文件中删除前导字节,然后将剩余字节写入 otput
- html - 路由激活时应用样式(过滤器)
- javascript - 使用 moment.js 将本地时间更改为 UTC+0
- oracle - 在 Oracle 中使用 owner.table 插入数据时出错,在没有所有者的情况下工作
- android - 如果我不使用 MediaExtractor,在媒体编解码器中使用哪个presentationTimeUs?