简体   繁体   中英

Android. Avoid scaling of background

In a start activity of our android application we're using a linearlayout with an background image for whole space.

The image size is 320x480 - the same as device resolution, we're using for testing.

The problem is, the image will be scaled und looks not so nice.

I tried to use imageview instead, but I've got black borders.

Some ideas, how to avoid scaling or how to get the proper size for background image?!

Thank you in advance.

Mur.

Create a background.xml file in res/drawable and use the following:

<?xml version="1.0" encoding="utf-8"?>
<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/background_image"
    android:gravity="center"/>

And use this background.xml as your LinearLayout's background.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM