1

我有一個向量繪製的問題,我設置爲我的RelativeLayout的背景。它不是水平填充屏幕。背景可繪製向量不填充屏幕

這裏是我的RelativeLayout代碼:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/my_drawable"> 

     ... 
     some text views etc. 
     ... 

    </RelativeLayout> 

和矢量繪製對象my_drawable,如果它有助於把它貼:

<vector android:height="24dp" android:viewportHeight="110.0" 
    android:viewportWidth="110.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> 
    <path android:name="border_path" android:fillColor="@color/color_1" android:fillAlpha="1" 
     android:pathData="M105.13,107.51L4.89,107.51A2.38,2.38 99.69,0 1,2.51 105.13L2.51,4.89A2.38,2.38 119.37,0 1,4.89 2.51L105.13,2.51A2.38,2.38 119.37,0 1,107.51 4.89L107.51,105.13A2.38,2.38 99.69,0 1,105.13 107.51z" 
     android:strokeAlpha="1" android:strokeColor="@color/color_2" android:strokeWidth="5"/> 
</vector> 

和下面的屏幕截圖。如你所見,它不能填滿整個寬度。 enter image description here

任何建議/解決方案高度讚賞!一幀佈局

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout 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:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:scaleType="fitXY" 
       android:src="@drawable/sample" 
       android:text="Hello World!" /> 

     </FrameLayout> 

    </RelativeLayout> 

output

+0

圖像未加載 –

回答

0

地方圖像視圖看起來像一個源圖像的生成的矢量可繪製從含有一些填充。確保刪除它並再次繪製drawable。

+0

同樣的問題,這裏沒有改變。 – MMagician

0

內部

+0

我試過了,似乎沒有填充。我查看了pathData中的位置,似乎達到了由視口專有名稱指定的角點(這裏是簡單的邏輯,我不是矢量圖形專家,可能是錯誤的)。 – MMagician

0

我知道這不是我正在尋找的解決方案,但不是玩矢量,我只是創建了一個形狀可繪製的XML。我的目標是實現陰影,因此我開始導入SVG,但實際上我能夠使用圖層列表實現陰影。

如果有人遇到了解決方案,我會很好奇。

謝謝大家!