Проблемы с блесной на относительном слое xml - PullRequest
0 голосов
/ 10 ноября 2010

Я делаю XML-файл макета, и я хочу, чтобы мой счетчик был справа от текста, но у меня возникли проблемы ... Когда я тестирую макет, мой счетчик не в правильной возможности, немного больше и имеет очень маленькую длину, не 180px, как я сказал в макете.

есть 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 Ответ

1 голос
/ 10 ноября 2010

Действительно ли необходимо, чтобы все элементы в вашем макете относились друг к другу?Конечно, это не так из всех свойств, которые вы устанавливаете для каждого элемента.

Я бы порекомендовал попробовать что-то вроде LinearLayout, а затем, если критично, что определенный элемент является Относительным к другому элементу, используйте RelativeLayout.внутри LinearLayout для этих конкретных предметов.

...