Xamarin контролирует укладку друг на друга - PullRequest
0 голосов
/ 17 сентября 2018

Я новичок в Xamarin, я вижу учебники, подобные приведенным здесь: https://docs.microsoft.com/en-us/xamarin/android/get-started/hello-android/hello-android-quickstart?tabs=vswin

, и предполагается, что дизайнер axml "привязывает" элементы управления к границе других элементов управления, которые вы перечислили, номой не работает таким образом.Это просто складывает их друг на друга.Любая подсказка, как исправить это?Я искал некоторое время, но кажется, что ни у кого больше нет этой проблемы.

Например, все они просто помещаются в верхнем левом углу панели и даже когда расположены "правильно"внизу другого элемента управления они просто привязываются к верхнему левому углу.

Редактировать: Общий доступ к XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px"
tools:gridSpec="1|8|#0093eeff|K:#ee8700ff:16,l:72,l:16,r|S:#83ee00ff:16,0,l:16,56,l:16,0,r">
<TextView
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:minWidth="25px"
    android:minHeight="25px"
    android:id="@+id/textView1"
    android:layout_toLeftOf="@id/textView1"
    android:layout_toRightOf="@id/editText1" />
<TextView
    android:text="Text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/PhoneNumberText"
    android:id="@+id/textView2" />
<Button
    android:text="Translate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/PhoneNumberText"
    android:id="@+id/TranslateButton"
    android:layout_above="@id/PhoneNumberText" />
<EditText
    android:layout_height="wrap_content"
    android:layout_below="@id/PhoneNumberText"
    android:id="@+id/PhoneNumberText"
    android:layout_toLeftOf="@id/textView1"
    android:layout_marginTop="0.0dp"
    android:layout_marginBottom="0.0dp"
    android:text="1-855-xamarin"
    android:layout_width="wrap_content" />
</RelativeLayout>

1 Ответ

0 голосов
/ 17 сентября 2018

Xamarin Контролирует укладку друг на друга

Ваш .axml имеет несколько ошибок.

В вашем textView2:

<TextView
    ...
    android:id="@+id/textView1"
    android:layout_toLeftOf="@id/textView1"
    android:layout_toRightOf="@id/editText1" />
//I didn't find where you define the id -- editText1

И обратите внимание: Круговые зависимости не могут существовать в RelativeLayout

Какой макет вы хотите достичь?

Что-то вроде изображения, которое вы публикуете в приведенной выше ссылке?

enter image description here

Если это так, вы можете изменить файл макета на:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:text="Enter a Phoneword:"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView1" />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/PhoneNumberText"
        android:text="1-855-XAMARIN" />
    <Button
        android:text="Translate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/TranslateButton" />
    <TextView
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/TranslatedPhoneWord" />
</LinearLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...