Android 编辑文本框不会在小屏幕上缩放
我的视图中有一个无法用编辑文本框解决的问题。 如果我在eclipse中预览任何视图,EditText框在小屏幕和大屏幕上看起来都很好,并且按预期缩放。但在小屏幕上,它们在屏幕上的高度更大。它们看起来在宽度上可以缩放,但在高度上会增加,在文本和边框之间留下更多的边距 xml非常小:Android 编辑文本框不会在小屏幕上缩放,android,Android,我的视图中有一个无法用编辑文本框解决的问题。 如果我在eclipse中预览任何视图,EditText框在小屏幕和大屏幕上看起来都很好,并且按预期缩放。但在小屏幕上,它们在屏幕上的高度更大。它们看起来在宽度上可以缩放,但在高度上会增加,在文本和边框之间留下更多的边距 xml非常小: <EditText android:id="@+id/width" android:layout_height="wrap_content" android:layout_width="fill_parent
<EditText android:id="@+id/width"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="Slab Width (mm)"
android:inputType="phone"
>
</EditText>
我本以为盒子会按比例调整高度以适应屏幕。
我感到惊讶的是,它在高度上不成比例。
我很震惊,它的身体高度越来越高
小屏幕:
编辑:实际上是QVGA和WQVGA屏幕有这个问题
我认为您需要完整的xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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>
尝试为您的EditText
显式指定android:padding
,看看这是否有帮助。好的,可能是您的问题在清单中
应在此处声明对所有屏幕的支持
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true" />
另外,SDK Api 4也应该在清单中声明。从1.6开始,首先支持小屏幕
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
希望,我没有错你得更准确些。什么尺寸?最重要的是,您测试的屏幕密度是多少?我刚刚在帖子中添加了完整的xml。。!这对我来说很奇怪,为什么它会被缩放,尽管你使用高度包裹内容,我认为这里可能发生的是:线性布局在高度上拉伸,并且拉伸内容。如果我是对的,怎么。。?因为它被设置为包装内容。我想,我们也遇到了同样的问题,因为Android 1.6将首先支持小屏幕。看到我的回答了吗?我把这个添加到舱单上,一点也不高兴。。我刚刚通过测试得出的结论是:我创建了一个新项目Android1.6,api4,然后在布局中添加了一个editText区域。。工作很好。。!因此,我遇到的问题可能不是我的xml。。它更可能出现在清单或活动中。我还要说,您的xml是正确的。您是否尝试将项目的目标sdk更改为1.6?或者甚至到2.2?我想我已经发现了问题,在你的回答的帮助下,我已经建立了项目,目标是2.1 api级别7。。。在此阶段将min sdk和目标sdk添加到清单并不能解决问题。只是在清单中创建了一个错误。版本不匹配..!>只是在清单中创建了一个错误。版本不匹配..!>奇怪的我的项目清单中有minSDK=3,targetSdk=4,我的项目的构建目标是8,我没有得到任何错误更准确地说,这是一个警告:“属性minSDK版本(4)低于项目目标api级别7”