背景圖片不被拉伸的簡單解決方案

background會根據組件給定的長寬進行拉伸,而src就存放的是原圖的大小,不會進行拉伸。src是圖片內容(前景),bg是背景,可以同時使用。

可以使用xml src指定圖片,這樣圖片就不會根據view長寬進行拉伸了 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@id/toolbar_bg_bmp"
    android:src="@drawable/toolbar_bg"
    android:tileMode="disabled" android:gravity="top" >
</bitmap>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章