【问题标题】:Remove spacing between views in NativeScript在 NativeScript 中删除视图之间的间距
【发布时间】:2017-05-02 10:35:19
【问题描述】:

我在 stacklayout 中有按钮,但默认情况下它会增加子视图之间的间距。我怎样才能删除它?

    <ScrollView orientation="horizontal" (scroll)="onScroll($event)" id="mainScrollViewButtons" row="0">
        <StackLayout id="mainButtonBox" orientation="horizontal">
            <Button class="btn btn-primary" margin="0" marginLeft="0" marginRight="0" width="120" text="Blue" (tap)="onBlue()"  (swipe)="onSwipe($event)"></Button>
            <Button class="btn btn-primary" margin="0" marginLeft="0" marginRight="0" width="120" text="Purple" (tap)="onPurple()" (swipe)="onSwipe($event)"></Button>
            <Button class="btn btn-primary" margin="0" width="150" text="Yellow" (tap)="onYellow()" (swipe)="onSwipe($event)"></Button>
            <Button class="btn btn-primary" margin="0" width="120" text="Red" (tap)="onYellow()" (swipe)="onSwipe($event)"></Button>
        </StackLayout>
    </ScrollView>

【问题讨论】:

    标签: angular telerik nativescript


    【解决方案1】:

    你可以使用下面的“hack”

    在您的 app.css 中

    Button {
      background-color: rgba(255, 0, 0, 0.0);
      border-color:rgba(255, 0, 0, 0.0);
      border-width: 1;
    }
    

    关于解释按钮边框背后问题的讨论可以找到here

    【讨论】:

    • 它失去了涟漪效应。我试着输入Label。它与此解决方案具有相同的结果
    • 是的,它肯定会失去涟漪效应,因为这是来自 Android 中按钮的默认背景。这也是原生 Android 中的常见问题,因此解决方案是提供您自己的涟漪效应。在 nativescript 中有一个插件叫做 nativescript-ripple
    • 是否支持 nativescript-angular ?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-20
    • 2023-03-27
    • 2017-03-09
    • 1970-01-01
    相关资源
    最近更新 更多