Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.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 调整StackLayout元素的高度_Android_Xamarin_Cross Platform - Fatal编程技术网

Android 调整StackLayout元素的高度

Android 调整StackLayout元素的高度,android,xamarin,cross-platform,Android,Xamarin,Cross Platform,我对Xamarin表单非常陌生,我刚刚接到任务,为这个应用程序的Android版本调整UI。在安卓手机上,用户界面看起来不错,但在平板电脑上却有点小。因此,当设备是平板电脑时,我开发了一个新页面,但我似乎无法调整StackLayout元素的高度。代码如下: <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout VerticalOptions="Fill" Sp

我对Xamarin表单非常陌生,我刚刚接到任务,为这个应用程序的Android版本调整UI。在安卓手机上,用户界面看起来不错,但在平板电脑上却有点小。因此,当设备是平板电脑时,我开发了一个新页面,但我似乎无法调整StackLayout元素的高度。代码如下:

<ListView.ItemTemplate>
  <DataTemplate>
    <ViewCell>
      <StackLayout VerticalOptions="Fill" Spacing="0" Padding="0" Margin="0">
        <StackLayout VerticalOptions="Fill" HeightRequest="60" Padding="2" Orientation="Horizontal">
          <Label VerticalOptions="Center" FontSize="19" Margin="14,0,0,0" Text="{Binding Name}" TextColor="White" ></Label>
          <Image VerticalOptions="Center" HorizontalOptions="EndAndExpand" HeightRequest="50" WidthRequest="30" Source="imgArrow.png"></Image>
        </StackLayout>
        <BoxView Margin="0,2,0,0" HeightRequest="0.5" BackgroundColor="White" />
      </StackLayout>
    </ViewCell>
  </DataTemplate>
</ListView.ItemTemplate>

不管我在HeightRequest字段中输入了什么值,它看起来总是一样的。我肯定我错过了一些基本的东西。下面是它在屏幕上的样子。我只是想让它占用更多的空间,这将涉及到增加字体大小,但当我这样做时,它只是看起来很糟糕。我非常感激能得到的任何帮助。谢谢

是否尝试将listview的“hasRows”属性设置为true

我想它会解决你的字体大小问题

  • 检测是否为平板电脑/手机,为您要使用的变量设置正确的高度
  • 由于您处于DataTemplate中,因此将HeightRequest绑定到您设置的变量 对于datatemplates之外的简单情况,可以为元素指定x:name,然后在构造函数中使用这些名称设置widthrequests