0

我正在做一个 xml 布局文件,我想让我的微调器位于 textview 的右侧,但是我遇到了问题......当我测试布局时,我的微调器不在正确的位置,它有点向下而且它的长度非常小,不是我在布局中说的 180 像素。

有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"/>

4

1 回答 1

1

布局中的所有项目是否真的有必要彼此“相对”?从您在每个项目上设置的属性来看,它肯定不会以这种方式出现。

我建议尝试类似 LinearLayout 的东西,然后如果某个项目相对于另一个项目至关重要,请在 LinearLayout 中为这些特定项目使用 RelativeLayout。

于 2010-11-10T14:11:13.587 回答