开发者

EditText boxes do not scale on small screens

开发者 https://www.devze.com 2023-01-27 22:24 出处:网络
I have a problem i cant resolve with EditText boxes in my views. If i preview any of my views in eclipse, the EditText boxes look fine in small and larger screens, and appear to scale as expected. But

I have a problem i cant resolve with EditText boxes in my views. If i preview any of my views in eclipse, the EditText boxes look fine in small and larger screens, and appear to scale as expected. But in small screens they appear larger in height on the screen. They appear to scale on the width ok, but grow in height, leaving more margin between the text and the border.

The xml is very small:

<EditText android:id="@+id/width" 
android:layout_height="wrap_content" 
android:layout_width="fill_parent" 
android:hint="Slab Width (mm)" 
android:inputType="phone"
>
</EditText>

I would have expected the box to be scaled in height to suit the screen. I am surprised it does not scale in height. I am shocked it gets larger in physical height...????

Small screen: http://www.doobox.co.uk/rapidimages/smallscreen.png

edit: Its actually QVGA & WQVGA screens that have this problem..!

I think your going to need full xml:

<?xml version="1.0" encoding="utf-8"?>
<Relat开发者_运维知识库iveLayout
android:id="@+id/widget36"
android:background="@drawable/linen_bg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<LinearLayout
android:id="@+id/main_linear"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dip" android:layout_marginRight="20dip" android:layout_height="wrap_content">
<ImageView
android:id="@+id/logo"
android:background="@drawable/conc_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" 
android:layout_marginTop="15dip"
>
</ImageView>
<TextView android:text="Slab Calculator" 
android:id="@+id/TextView01" 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="20sp" 
android:textColor="#333333" 
android:layout_marginTop="20dip">
</TextView>



<EditText android:id="@+id/length" 
android:layout_width="fill_parent" 
android:inputType="phone" 
android:fitsSystemWindows="true" 
android:hint="Height of Slab (mm)" 
android:layout_height="wrap_content">
</EditText>



<TextView android:text="**.** Cubic Meter's" 
android:id="@+id/slab_result" 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" 
android:textColor="#333333" 
android:layout_marginTop="5dip">
</TextView>

<TextView android:text="£**.** Total" 
android:id="@+id/slab_cost" 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" 
android:textColor="#333333" 
android:layout_marginTop="5dip">
</TextView>
</LinearLayout>
<RelativeLayout android:id="@+id/bottom_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="20dip"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
>
<Button
android:id="@+id/calculate_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:drawableTop="@drawable/calculate" 
android:text="Calculate" 
android:background="@android:color/transparent">
</Button>
</RelativeLayout>
</RelativeLayout>


Ok, may be your problem is in your Manifest.

Support for all screens should be declared there

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

Another thing, SDK Api 4 should be declared in your Manifest as well. Small screens will be supported first from 1.6

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

Hope, I'm not so wrong


Try explicitly specifying android:padding for your EditText and see if that might help.

0

精彩评论

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