2015-11-11 30 views

回答

1

可以調整可通過設置ImageViewsandroid:scaleType到合適的值,使之能夠處理正在祕密包含在VectorDrawables源填充包含一個VectorDrawables源圖像(.SVG.PSD)內的任何「隱含的」填充圖片。您還需要設置android:adjustViewBounds="true"

例如,假設您的圖片顯示時VectorDrawable有一些令人討厭的padding。你不知道爲什麼它在那裏,因爲你沒有在ImageView上設置任何android:paddingStart ......你需要做的是設置ImageViewsandroid:scaleTypefitStartandroid:adjustViewBoundstrue

TL;博士

調整你的ImageViewsandroid:scaleType處理包含在你的VectorDrawable的源文件(.SVG.PSD)任何 「隱含的」 填充。還設置了android:adjustViewBounds="true"

簡單的例子:

<ImageView android:id="@+id/vectorDrawable_imageView" 
      <!--Other ImageView settings--> 
      android:adjustViewBounds="true" 
      android:scaleType="fitStart" 
      app:srcCompat="@drawable/vector_with_implicit_padding_at_start" 
/> 

這將刪除惱人的「隱含的」填充,這是你的VectorDrawable的開始。

注意:根據您的渲染需要調整android:scaleType

1

此填充位於某些圖標上,以便所有圖標均可正確對齊。例如,如果在該對話框中選擇ic_3d_rotation_24dp,則會看到圖標一直延伸到邊界的邊緣。

PS如果你的目標是擁有all your sizes be a multiple of 8dp,事情會很好地排隊,看起來不錯。

+0

謝謝!我不知道。我認爲這可能是一個錯誤或功能可以被禁用。 – Guy