【问题标题】:Resizing Android Drawable Item调整 Android 可绘制项目的大小
【发布时间】:2021-06-01 18:22:09
【问题描述】:

如何调整可绘制项目的大小?我正在尝试修改 Android 12 启动画面的 png 图标。

这是我的主题.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
    <style name="Theme.SimpleSplashScreen" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/purple_500</item>
        <item name="colorPrimaryVariant">@color/purple_700</item>
        <item name="colorOnPrimary">@color/white</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor" xmlns:tools="http://schemas.android.com/tools">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
        <item name="android:windowSplashScreenAnimatedIcon">@drawable/e_espn_logo</item>
    </style>
</resources>

我正在尝试调整这一行中可绘制对象的大小:

<item name="android:windowSplashScreenAnimatedIcon">@drawable/e_espn_logo</item>

【问题讨论】:

    标签: android xml android-studio drawable


    【解决方案1】:

    你可以添加一个图层列表drawable并在你的主题中使用它:

    在 splash_logo.xml 中:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools">
        <item
            android:width="your_icon_width"
            android:height="your_icon_height"
            android:drawable="@drawable/e_espn_logo"
            android:gravity="center"
            tools:ignore="UnusedAttribute" />
    </layer-list>
    

    然后:

    <item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_logo</item>
    

    【讨论】:

      【解决方案2】:

      在可绘制代码中创建尺寸,或更改高度和宽度

      【讨论】:

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