0
我使用XML繪製:圖片無法在Android中正確縮放。
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/splashscreen"
android:tileMode="disabled" android:gravity="top" >
</bitmap>
這是我在佈局中的ImageView:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/splash_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
/>
</RelativeLayout>
但無論我做什麼,它不適合屏幕,僅出現在中心作爲一個小圖像。我哪裏錯了?
您應該使用'MATCH_PARENT','FILL_PARENT'已棄用。從[ViewGroup.LayoutParams](http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html)'FILL_PARENT(在API級別8和更高的重命名MATCH_PARENT),這意味着該視圖希望成爲大如其父(減去填充)' – quinnjn
單詞「過時」不是在上面的鏈接提到。閱讀兩遍!它只是說它已被重命名(重命名!=棄用)。 –
對不起,我很抱歉,我猜MATCH_PARENT被改名了。但我認爲其他部分是正確的,這是我爲我的解決方案所做的。爲不同的屏幕尺寸製作不同的圖像。 –