矢量drawable不缩放

时间:2017-06-19 15:04:40

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

我试图将我的linearlayout背景设置为矢量drawable,但是它不是缩放以填充整个布局,下面是我的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">

以下是我的vector 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"/>

谢谢

1 个答案:

答案 0 :(得分:0)

如果要为布局设置绿色背景,为什么不尝试这样做。

更改您的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>