2017-05-02 21 views
0

我在堆棧佈局中有按鈕,但默認情況下它會在子視圖之間添加間距。我如何刪除它?在NativeScript中刪除視圖間的間距

<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> 

回答

0

您可以使用下面的「黑客」

在app.css

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

論解釋按鈕邊框後面的問題可以發現here

+1

它失去了連鎖反應。我試圖把'標籤'。它與此解決方案具有相同的結果 –

+0

是的,它肯定會失去連鎖反應,因爲它來自Android中按鈕的默認背景。這在原生Android中也是一個常見問題,因此解決方案是提供自己的連鎖效應。在nativescript中有一個插件,稱爲nativescript-ripple –

+0

它支持nativescript-angular嗎? –