2010-06-25 102 views
2

在模擬器中,edittext和按鈕的大小看起來不錯,但是在motorola里程碑中,它們都非常小。我認爲有不同類型的屏幕布局。是否可以自動調整大小?我的XML如下:自動調整edittext和按鈕的大小和位置

<?xml version="1.0" encoding="utf-8"?><RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<EditText android:id="@+id/txtToText_e" 
android:layout_width="270px" 
android:layout_height="wrap_content" 
android:textSize="18sp" 
android:hint="Type To Compose" 
android:layout_alignParentBottom = "true" 
android:layout_alignParentLeft="true"/> <Button android:text="Send" 
android:id="@+id/btnDone_e" 
android:layout_width="85px" 
android:layout_height="wrap_content"  
android:layout_alignParentBottom = "true" 
android:layout_alignParentRight="true"/>         

要獲得自動重新調整大小的EditText而轉向手機,從縱向到橫向,我在AndroidManifest.xml

添加這些XML代碼
<supports-screens android:smallScreens="true" 
       android:normalScreens="true" 
       android:largeScreens="true" 
       android:anyDensity="true" /> 

但沒有變化= [。如何解決它?

謝謝。

回答

1

如果要根據屏幕密度更改尺寸,請使用dip代替px

+0

現在我用'dip'。將手機從縱向轉爲橫向時,我希望根據屏幕寬度自動調整文本框大小。肖像的尺寸仍然相同。 – soclose 2010-06-28 01:50:49

+0

@soclose:您可以使用維度資源('res/values/dimens.xml')指定寬度,併爲橫向('res/values-land/dimens.xml')設置不同的值。或者,對景觀有不同的佈局('res/layout-land/whatever.xml')。還有其他可能的解決方案。 – CommonsWare 2010-06-28 06:41:07

相關問題