想要没有底部边框的Native Script XML中的textView或textField

时间:2016-05-17 18:03:08

标签: nativescript

默认文本框有一个底部边框。 如何在没有底部边框的情况下获取Native Script XML中的textView或textField?

2 个答案:

答案 0 :(得分:4)

根据Nikolay的建议,以下内容应在样式表中进行

background-color: transparent;
border-color: transparent;

答案 1 :(得分:1)

一个可能的决定可能是删除textfield和textview border-bottom是设置背景颜色。这也会使边框变色。我会举个例子来说明一下

主要-page.xml

<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
  <StackLayout backgroundColor="red">
    <Label text="Tap the button" class="title"/>
    <Button text="TAP" tap="{{ onTap }}" />
    <Label text="{{ message }}" class="message" textWrap="true"/>
    <TextField hint="" id="tfield" text="tests textfield"/>
   <TextView hint="" id="tview" text="tests textView" editable="true" style="border-color:white; "  />


  </StackLayout>
</Page>

主要-page.js

   var main_view_model_1 = require("./main-view-model");
var color_1 = require('color');
// Event handler for Page "navigatingTo" event attached in main-page.xml
function navigatingTo(args) {
    // Get the event sender
    var page = args.object;
    var tf = page.getViewById("tfield");
    tf.borderColor = new color_1.Color("#ffffff");
    tf.backgroundColor = new color_1.Color(100, 255, 0, 0);
    var tv = page.getViewById("tview");
    tv.borderColor = new color_1.Color("#ffffff");
    tv.backgroundColor = new color_1.Color(100, 255, 0, 0);
    page.bindingContext = new main_view_model_1.HelloWorldModel();
}
exports.navigatingTo = navigatingTo;