开发者

Image won`t fit screen

开发者 https://www.devze.com 2022-12-24 19:59 出处:网络
I have a 320x480 image which I`d like to fit the whole screen. This is the main.xml code <ImageViewxmlns:android=\"http://schemas.android.com/apk/res/android\">

I have a 320x480 image which I`d like to fit the whole screen. This is the main.xml code

<ImageView   xmlns:android="http://schemas.android.com/apk/res/android">
        android:id='@+id/splash_medium'

        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 

        android:src="@drawable/wallpaper320x480"
         />

The screen shows the image but there is a considerable padding to the left and to the right, and a little bit to the top and to the bottom. I have tried setting android:padding to 0dip with no result.

Link to image, I can`t post images yet: screenshot

Any help would be a开发者_如何学JAVAppreciated.


This was probably an issue with the size of your picture and lack of scaling. If your picture doesn't have enough pixels to fill the screen and you don't tell it to stretch the picture, then you'll have gaps at the sides. The fix is to use android:scaleType="fitXY". Note, this applies to when the image is set with android:src="..." rather than android:background="..." as backgrounds are set by default to stretch and fit to the View. (The purpose of having both is that it lets you do things like having a frame around an image, by setting a frame as the background and the main image as the source.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号