【问题标题】:GridLayout in NativeScript not displaying properlyNativeScript 中的 GridLayout 无法正确显示
【发布时间】:2019-06-10 05:11:11
【问题描述】:

我的问题

我正在尝试在 NativeScript 中创建此屏幕:

我正在使用每个人都推荐的 GridLayout。我按照文档写信(我认为),这是我的结果:

如您所见,甚至没有接近。这是我的 XML:

<Page
    navigatingTo="onNavigatingTo"  
    xmlns="http://schemas.nativescript.org/tns.xsd">

    <ActionBar class="action-bar customActionBar">
        <!-- 
        Use the NavigationButton as a side-drawer button in Android
        because ActionItems are shown on the right side of the ActionBar
        -->
        <NavigationButton ios:visibility="collapsed" icon="res://menu" tap="onDrawerButtonTap"></NavigationButton>
        <!-- 
        Use the ActionItem for IOS with position set to left. Using the
        NavigationButton as a side-drawer button in iOS is not possible,
        because its function is to always navigate back in the application.
        -->
        <ActionItem icon="res://navigation/menu" 
            android:visibility="collapsed" 
            tap="onDrawerButtonTap"
            ios.position="left">
        </ActionItem>
        <Label class="action-bar-title" text="Settings"></Label>
    </ActionBar>

    <GridLayout columns="2*, auto, auto" rows="75, auto, auto" width="100%" height="100%" backgroundColor="lightgray" >
    <Label text="Notifications" row="0" col="0"/>
    <Label text="Push" row="0" col="1" />
    <Label text="Email" row="0" col="2" />
<Label text="Messages" row="1" col="0"/>
<Switch checked="true" (checkedChange)="onCheckedChange($event)" class="m-15" row="1" col="1"></Switch>
 <Switch checked="true" (checkedChange)="onCheckedChange($event)" class="m-15" row="1" col="2"></Switch>
  </GridLayout>
</Page>


我试着玩弄这些数字,但它仍然无法像我需要的那样显示。

我做错了什么。你能帮帮我吗?

谢谢。

约翰

【问题讨论】:

  • 请参阅nslayouts.com 了解有关布局的更多信息。
  • 嗨 Manoj,我一如既往地欣赏你的技能和 cmets。我确实通读了文档。也许我只是不理解某些事情,但我向你保证,这并不是因为缺乏尝试自己。我将再次重新阅读它们。很明显我错过了一些东西。感谢您的推动。

标签: css nativescript


【解决方案1】:

看看有没有类似

columns="4*, *, *"

产生你想要的。然后,您可以看到 css 为列添加填充和居中。

【讨论】:

  • 是的,大卫。这似乎是对的。谢谢你。我绝对需要更好地理解 * 。再次感谢
猜你喜欢
  • 2019-12-07
  • 1970-01-01
  • 2017-07-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-23
  • 2018-06-09
  • 1970-01-01
相关资源
最近更新 更多