xaml - 水平列表视图中的内容视图未展开
问题描述
我通过列表视图旋转 270 度和数据模板旋转 90 度的内容视图创建动态水平列表视图,但内容视图没有扩展
我尝试设置 VerticalOptions="FillAndExpand" 和 HorizontalOptions="FillAndExpand" 并尝试设置 RelativeLayout.WidthConstraint 和 RelativeLayout.HeightConstraint 但它不起作用
<RelativeLayout HeightRequest="40" BackgroundColor="Pink" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<ListView Rotation="270" x:Name="Horizonlist" ItemsSource="Hlist" RowHeight="130" SeparatorVisibility="Default" SeparatorColor="#EEEEEE" BackgroundColor="Gray"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5, Constant=-15}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=-0.5, Constant=15}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=Constant, Constant=40}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ContentView Rotation="90" BackgroundColor="Blue" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" HeightRequest="200" WidthRequest="200">
<StackLayout Spacing="0" BackgroundColor="Green" Orientation="Vertical" HorizontalOptions="FillAndExpand" WidthRequest="200" HeightRequest="200">
<Label Rotation="0" Text="AAAAAAAAAAAAAA" WidthRequest="200" HeightRequest="200" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" VerticalTextAlignment="Center" TextColor="Black" BackgroundColor="Yellow"/>
</StackLayout>
</ContentView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</RelativeLayout>
解决方案
<ScrollView Orientation="Horizontal"> <StackLayout Orientation="Horizontal" BindableLayout.ItemsSource="{Binding carousel_list}" IsVisible="{Binding carousel_visibility}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal">
<Image Source="{Binding image}" VerticalOptions="Start" WidthRequest="300"/>
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</ScrollView>
为了实现类似输出的水平列表视图,您可以使用上述代码中所示的可绑定布局
推荐阅读
- java - 测试顺序会影响性能结果吗?
- c# - 从固定长度的字符串映射到唯一的数字
- android - 如何从图库中选择图像并将其上传到数据库
- android - RecyclerView lateinit 属性 mClickListener 没有被初始化
- javascript - 如何忽略源自其他域链接的脚本的 TrackJS 错误?
- polymer - 有没有办法在 Polymer 1 中导入 Polymer 3 组件?
- ios - IOS后台监听音频路由变化
- angular - 当没有数据存在时,带有 ng2charts 条形图的 Angular 显示 NAN%
- typescript - 使用 angular8 将 ES5 类导入打字稿会引发 NullInjectorError:StaticInjectorError
- java - 多个凌空请求同时