Kevin Burandt
Kevin Burandt

Reputation: 1990

My Touch 4g text in EditText is vertically centered too high

I have a MyTouch 4g user that has submitted the following screenshots (sorry can't post images):

Bad format

Which is supposedly 480x800. Using 480x800 in the simulator all works fine:

Good format

Here is the relevant xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="vertical">
        <TableRow android:background="@drawable/gradient_row"
            android:paddingTop="4dip">
            <TextView 
                android:id="@+id/outDiameterLabel" 
                android:paddingTop="6dip" 
                android:paddingRight="5dip"
                android:layout_gravity="right" 
                android:layout_height="40dip"
                android:layout_width="wrap_content" 
                android:textColor="#FFFFFF" 
                android:textSize="15dip"
                android:text="@string/outDiameterLabel" />
            <EditText 
                android:id="@+id/outExactDiameter"
                android:layout_height="40dip" 
                android:layout_width="wrap_content"
                android:gravity="center" 
                android:focusable="false" 
                android:numeric="decimal" />
            <EditText 
                android:id="@+id/outRoundedDiameter"
                android:layout_height="40dip" 
                android:layout_width="wrap_content"
                android:gravity="center" 
                android:focusable="false" 
                android:numeric="decimal" />
        </TableRow>
    </TableLayout>
</LinearLayout>
</ScrollView>

It also appears to be off on the width. If you look at the inputs on the bottom notice how the last button on the right is truncated. For the rest, the width is okay. I don't know how image was captured, it is 452 x 640. His phone: HTC MyTouch 4G, Android 2.2.1, Kernel 2.6.32.21-g899d047, Build 1.17.531.2 CL277036 release-keys, Software Number 7.17.531.2 Browser ver. WebKit 3.1. He has also tried un-install and re-install.

I cannot reproduce this on any device in my possession or in the emulator. Other than buying or borrowing a myTouch 4g does anybody have any ideas for a fix?

Kevin

Upvotes: 0

Views: 379

Answers (1)

adamp
adamp

Reputation: 28932

It looks like 40dip is not an appropriate height for those fields and the text is getting clipped by the content bounds of the 9-patch background of the EditText. Your Spinner widgets above are getting similarly clipped in both screenshots, which is why the little down arrows to the right have strange shapes rather than a clean triangle.

There are two simple options available. You could relax your 40dip height restriction on the affected fields and use wrap_content instead. This is the easiest (and probably best) approach for your situation.

Alternatively you could create your own styles for the affected widgets, including your own 9-patches for focused, disabled, pressed, etc. states. This would let you guarantee that the visuals and metrics for the fields are compatible with your height restriction on all devices.

Upvotes: 2

Related Questions