无法在Xamarin.Forms中使用LinearLayout

时间:2018-10-26 17:14:21

标签: android xamarin xamarin.forms

我正在学习Xamarin.Forms,同时遵循以下Android Linear Layout的文档-https://developer.android.com/reference/android/widget/LinearLayout

我收到此错误

  

错误XLS0414找不到类型'LinearLayout'。验证你   不会缺少程序集引用,并且所有引用   程序集已建立。 DPM MainPage.xaml

也在“输出”窗口中,消息显示

  

在xmlns中找不到类型LinearLayout   http://xamarin.com/schemas/2014/forms

这是视图

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:DPM"
             x:Class="DPM.MainPage">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:paddingLeft="16dp"
   android:paddingRight="16dp"
   android:orientation="horizontal"
   android:gravity="center">
        <!-- Place new controls here -->
        <Label Text="Prueba" 
           HorizontalOptions="Center"
           VerticalOptions="CenterAndExpand" />
        <Label Text="Welcome to Xamarin.Forms!" 
           HorizontalOptions="Center"
           VerticalOptions="CenterAndExpand" />
        <Label Text="Bottom" 
           HorizontalOptions="Center"
           VerticalOptions="CenterAndExpand" />
    </LinearLayout>
</ContentPage>

如果需要更多信息来解决此问题,请通过评论告知我

1 个答案:

答案 0 :(得分:1)

Xamarin.Forms中没有LinearLayout,您可能会对Xamarin Native感到困惑。

有一个可以在Xamarin.Forms中实现的布局列表。

另外,您可能正在为这种结构寻找StackLayout

Xamarin.Forms Layouts