首页 > 解决方案 > 抽屉导航器内的矢量图像不会因不同的屏幕分辨率而改变

问题描述

我在抽屉导航器内的图像视图中使用矢量资产。但是此图像不会针对不同的屏幕分辨率更改大小。这是抽屉导航器的代码。我在这里使用 2 个抽屉导航器来对齐菜单底部

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main">

        <ImageView
            android:id="@+id/logo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:scaleType="fitCenter"
            android:adjustViewBounds="true"
            android:layout_gravity="center"
            app:srcCompat="@drawable/ic_logo" />

        <android.support.design.widget.NavigationView
            android:id="@+id/navigation_drawer_bottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:fitsSystemWindows="true"
            app:menu="@menu/activity_main_drawer">

            <TextView
                android:id="@+id/version"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|right"
                android:clickable="true"
                android:gravity="bottom"
                android:onClick="onClick"
                android:textColor="@color/cardview_dark_background" />

        </android.support.design.widget.NavigationView>

    </android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>

我尝试了很多方法,但仍然没有找到解决方案。请帮忙

标签: androidandroid-layoutnavigation-drawerandroid-vectordrawable

解决方案


推荐阅读