2010-11-10 61 views
0

我在做一個xml佈局文件,我想讓我的微調在textview的右邊,但我有問題......當我測試佈局時,我的微調不是在正確的位置上,它會下降一點,它的長度非常小,不像我在版面中所說的那樣是180px。在相對佈局xml上的微調問題

存在的xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 

<TextView 
    android:id="@+id/PermissionLabel" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/perlabel" 
    android:layout_marginLeft="15dip" 
    android:layout_below="@id/salto3"/> 
<Spinner 
    android:id="@+id/Permission" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:prompt="@string/perlabel" 
    android:layout_alignBaseline="@id/PermissionLabel" 
    android:layout_alignParentRight="true" 
    android:width="180px" 
    android:layout_marginRight="20dip"/> 
<TextView 
    android:id="@+id/salto4" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/saltodelinea2" 
    android:layout_below="@id/PermissionLabel"/> 
<TextView 
    android:id="@+id/HoursRangeLabel" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/hoursrangelabel" 
    android:layout_below="@id/salto4" 
    android:layout_marginLeft="15dip"/> 
<EditText 
    android:id="@+id/From" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_alignBaseline="@id/HoursRangeLabel" 
    android:width="70px" 
    android:layout_alignLeft="@id/Email" 
    android:layout_marginRight="20dip"/> 
<TextView 
    android:id="@+id/ToLabel" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/tolabel" 
    android:layout_alignBaseline="@id/From" 
    android:layout_toRightOf="@id/From" 
    android:layout_marginLeft="-10px"/> 
<EditText 
    android:id="@+id/To" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="" 
    android:layout_alignBaseline="@id/From" 
    android:width="70px" 
    android:layout_marginRight="20dip" 
    android:layout_alignParentRight="true"/> 

回答

1

真的有必要在你的佈局中的所有項目都是「相對」對方?它肯定不會從您在每個項目上設置的屬性出現。

我會建議嘗試類似於LinearLayout的東西,然後如果某個項目相對於另一個項目至關重要,請在LinearLayout中使用RelativeLayout來處理這些特定項目。

+1

好的謝謝!我會做的! – NullPointerException 2010-11-10 15:01:07