Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用Visual Studio 2017在Xamarin上格式化布局_Android_Xamarin_Xamarin.android_Android Linearlayout - Fatal编程技术网

Android 使用Visual Studio 2017在Xamarin上格式化布局

Android 使用Visual Studio 2017在Xamarin上格式化布局,android,xamarin,xamarin.android,android-linearlayout,Android,Xamarin,Xamarin.android,Android Linearlayout,我正在尝试在我的移动应用程序上创建一个页面,显示学生住宿的列表。它应该显示地址,然后在下面有一个按钮,链接到显示更多信息的页面。 我尝试过使用LinearLayout和RelativeLayout(如下所示) 我用来创建这个的代码是 LinearLayout newLayout = new LinearLayout(Application.Context); TextView displayAddress = new T

我正在尝试在我的移动应用程序上创建一个页面,显示学生住宿的列表。它应该显示地址,然后在下面有一个按钮,链接到显示更多信息的页面。 我尝试过使用LinearLayout和RelativeLayout(如下所示)

我用来创建这个的代码是

                    LinearLayout newLayout = new LinearLayout(Application.Context);
                TextView displayAddress = new TextView(Application.Context);
                displayAddress.Text = "Address: " + accomodation.address1 + ", " + accomodation.address2 + ", " +
                    accomodation.city + ", " + accomodation.postcode;
                newLayout.AddView(displayAddress);
                Button moreInformation = new Button(Application.Context);
                moreInformation.Text = "More Info";
                moreInformation.SetY(displayAddress.GetY() + 100);
                newLayout.AddView(moreInformation);
                mainLayout.AddView(newLayout);

是否有任何方法可以格式化任何一种布局,使按钮位于文本下方?谢谢。

您可以创建一个
.axml
布局来实现此功能,例如:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
  <TextView
      android:id="@+id/textView_displayAddress"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="Address:  accomodation.address1  accomodation.address2 accomodation.city  accomodation.postcode" />
  <Button
      android:id="@+id/moreInformation"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="moreInfo" />
</LinearLayout>


.

您的问题解决了吗?