【问题标题】:Vector drawable not scaling矢量可绘制不缩放
【发布时间】:2017-06-19 15:04:40
【问题描述】:

我正在尝试将我的线性布局背景设置为可绘制的矢量,但它不会缩放以填充整个布局,下面是我的 xml:

<LinearLayout
    android:id="@+id/ideaBody"
    android:layout_width="220dp"
    android:layout_height="229dp"
    android:background="@drawable/ic_greenbackground"
    android:orientation="horizontal"
    android:scaleType="fitXY">

以下是我的向量xml;:

<vector android:height="500dp" android:viewportHeight="297.0"
    android:viewportWidth="210.0" android:width="500dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillAlpha="0.42" android:fillColor="#008000"
        android:pathData="M1.14,40.02h58.21v60.59h-58.21z"
        android:strokeAlpha="0.76" android:strokeWidth="0.26458332"/>

谢谢

【问题讨论】:

    标签: android xml android-linearlayout drawable android-vectordrawable


    【解决方案1】:

    如果你想为你的布局设置绿色背景,为什么不试试这个呢。

    更改您的 XML 代码

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#73008000" />
            <stroke android:width="0.76dp" android:color="#BF008000" />
        </shape>
    </item>
    </selector>
    

    【讨论】:

    • 我有一系列复杂的矢量资产 id 想从inkscape 导入,所以这个解决方案不合适,谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-29
    • 1970-01-01
    • 2019-09-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多