【发布时间】:2018-09-16 21:19:18
【问题描述】:
我是 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>
【问题讨论】:
-
分享你的
xml代码 -
@Yupi 共享 xml。
-
有趣的是,我只是遇到了这个问题,我在 Chrome 之间切换并查看它,然后返回网站和 Visual Studio 上的说明。我正在阅读这篇文章并回到 VS,突然它们不再堆叠。他们都在使用 layout_below 并且它刚刚开始工作。我猜是 Xamarin 或 VS 中的某种错误。
-
我遇到了这个问题并关闭了 activity_main.axml 并重新打开它,然后它们处于正确的位置。
标签: android xamarin xamarin.android