tags:

views:

117

answers:

4

O.k....this is weird. I had my buttons looking fine last week, now something has changed.

My buttons on the eclipse emulator are much larger than on my device (Droid 2.1).

I checked my skin settings, screen size permissions, density factors....what am I missing?

My skin is set to WVGA854, but when the app goes to the phone the buttons are smaller!? Text and pictures are fine...looking the same as the emulator...just the buttons are shrunk!

Hmm....I know it has to be something simple...:)

UPDATE: Ok....posting xml;

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/pic">
 <Button
    android:id="@+id/strtbtn"
    android:textSize="8pt"
    android:layout_marginTop="50px"
    android:layout_marginLeft="20px"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Blahh"/>
 <Button
    android:id="@+id/contbtn"
    android:textSize="8pt"
    android:layout_marginTop="140px"
    android:layout_marginLeft="200px"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Blahh"/>
 <Button
    android:id="@+id/credbtn"
    android:textSize="8pt"
    android:layout_marginTop="530px"
    android:layout_marginLeft="20px"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Blahh"/>
 <Button
    android:id="@+id/miscbtn"
    android:textSize="8pt"
    android:layout_marginTop="610px"
    android:layout_marginLeft="80px"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Blahh"/>
 <Button
    android:id="@+id/blahhbtn"
    android:textSize="8pt"
    android:layout_marginTop="690px"
    android:layout_marginLeft="200px"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Blahh"/>

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/introanim"
    android:id="@+id/introanim"
    android:layout_gravity="center"
    android:layout_weight="1"/>

</RelativeLayout>
A: 

Hmm, if you had said it the other way around, I've have agreed. For me, sometimes the WVGA854 emulator craps out and shows everything in a tiny size on the screen. It's as if it's showing everything according to the 320x480 size, but since the screen is 2.5x bigger it's all too small. Unfortunately, you seem to have a different problem... Does restarting Eclipse and the emulator make any difference to the button sizes? That does it for me when the problem happens.

Or here's another idea - have you installed a custom theme on your phone? If your app uses default button drawables, then installing a new theme will have changed those. That could explain why you're seeing different things on your phone and emulator.

Steve H
Nope..been looking at this a couple days. Restarted many times with many different settings. It IS looking like emulator is showing 320x480, BUT spacing on pics and text is perfect. I DO see log errors when emulator is starting...wondering if that could be it. The only major change (of course) has been he 2.1 release lately, and my live wallpaper. I can run my app on my device to get spacing right, but REALLY would like emulator to match! BTW, my buttons are on Relative Layouts, which I have been reading have various issues...don't know!
Mike Droid
Relative layouts give strange issues when used with ListViews, but the problems are generally more linked to layout/alignment rather than button sizes. As mbaird said, post up your button XML file so we can have a closer look. Another thing to try is to set a custom background (or a different one if you are already doing that) to your buttons to see if that is being displayed properly. If it does display properly, then your problem is with whatever background you had been using before.
Steve H
A: 

My view on best practice for Android sizing. In your AndroidManifest.xml

    <supports-screens android:largeScreens="true"
    android:normalScreens="true" android:smallScreens="true"
    android:anyDensity="true" android:resizeable="true" />

Then throughout your layouts use dip (Device Independent Pixel) units for your measurements.

Jim Blackler
Tried that...is something else. I DID notice that the eclipse layouts are using some "medium density" screens...played with that for awhile and could not get anywhere...skins still show 240...
Mike Droid
A: 

I think it may have something to do with the Droid 2.1 update. The buttons in my apps got smaller once I downloaded the new version of Android.

sirconnorstack
I'm starting to wonder...either our problem is a coincidence or 2.1 on our device did this. I recall my buttons looked good on my device...I don't recall changing my button config's.....
Mike Droid
+2  A: 

Instead of using the "px" unit for your dimensions, use "dip". Or better, use wrap_content. The WVGA emulator uses a higher density. 10px on a high density (240dpi) display will look 1.5x times smaller than on a medium density display (160dpi.) To make them look the same, one would use 10dip instead. 10dip = 10px on medium density displays, and 15px on high density displays.

All the information you need can be found there: http://d.android.com/guide/practices/screens_support.html

Romain Guy
Perfect. That sure did it. I swear I tried that already (per other suggestion below). BTW, I have read your blog and read books that reference you! Thanks!
Mike Droid