Sergey Metlov
Sergey Metlov

Reputation: 26351

Why does image has larger size?

I'm using such layout:

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/logo"
    android:orientation="horizontal" >

The drawable/logo.xml:

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/login_logo"
    android:gravity="center" />

The drawable/login_logo.png has 280 pixels width, my Galaxy Tab screen width is 600px but in launched app I see the image takes almost all screen width and it is about 500px

Where did I make mistake?

SOLVED
By setting

<uses-sdk android:minSdkVersion="4" />

and putting image to drawable-hdpi

Upvotes: 1

Views: 92

Answers (3)

Android Killer
Android Killer

Reputation: 18509

  1. As you are saying it is for galaxy tab so it is coming under drawable-hdpi.So change the resolution of image with photoshop or something and put it inside drawable-hdpi.
  2. and try to use android:layout_width="wrap_content". instead of android:layout_width="fil_parent"

Upvotes: 2

0xC0DED00D
0xC0DED00D

Reputation: 20368

You are setting your picture in background, and the android:background tag uses 9 patch images. So your background always stretches to the width and height of the view. Your layout width is set to fill_parent, so the image width is fill_parent too. The solution could be to make a 9 patch image of the png you are using with .9.png extension. Read here for drawing 9 patch images - developer.android.com/guide/developing/tools/draw9patch.html

Upvotes: 1

kgiannakakis
kgiannakakis

Reputation: 104196

I suggest that you have a good read of the documentation. If you have placed your image in the drawable-mdpi folder, then in high density screens the image will appear to be 1.5x in size. You will have to provide different resolutions of your image for different screen densities.

Upvotes: 1

Related Questions