【问题标题】:Xamarin.Forms StackLayout+ListView on Android - layout on top of each otherAndroid 上的 Xamarin.Forms StackLayout+ListView - 相互叠加布局
【发布时间】:2015-08-04 18:40:18
【问题描述】:

在 ViewCell 的 StackLayout 内容中,如果我将 FontSize="Large" 属性放在第一个标签上,它将呈现在标签二的顶部。 调整整个 ViewCell 的大小时,似乎没有考虑它改变的高度。

Android 上存在问题,布局在 Windows Phone 模拟器上运行正常,或者在没有 ListView 的情况下使用。

<ListView x:Name="listView" BackgroundColor="Red">
  <ListView.ItemTemplate>
    <DataTemplate>
      <ViewCell>
        <StackLayout>
          <Label Text="LABEL ONE" FontSize="Large" BackgroundColor="Green" />
          <Label Text="LABEL TWO" BackgroundColor="Yellow" />
        </StackLayout>
      </ViewCell>
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>

是我遗漏了什么还是 Xamarin.Forms 生成的内容布局中的错误?

【问题讨论】:

  • 我从 Xamarin 得到确认,这是 Forms 1.4.5 中存在的错误。
  • 尝试使用 OnPlatform 标签

标签: xamarin.forms


【解决方案1】:

试试这个。您忘记了 ViewCell.View 标记。

<ListView x:Name="listView" BackgroundColor="Red">
  <ListView.ItemTemplate>
    <DataTemplate>
      <ViewCell>
      <ViewCell.View>
        <StackLayout>
          <Label Text="LABEL ONE" FontSize="Large" BackgroundColor="Green" />
          <Label Text="LABEL TWO" BackgroundColor="Yellow" />
        </StackLayout>
      </ViewCell>
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 2019-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多