【问题标题】:How to set border-radius to button in Native Script?如何在 Nativescript 中将边框半径设置为按钮?
【发布时间】:2015-11-27 06:31:18
【问题描述】:

我有一个按钮:

<Button text="TodoSomething" cssClass="button" tap="signIn"/>

platform.android.css

.button{
-webkit-border-radius: 80px;
-moz-border-radius: 80px;
border-radius: 80px;}

但是border-radius 不起作用。在Supported Properties 写道,原生脚本支持border-radius

【问题讨论】:

    标签: android ios xml nativescript


    【解决方案1】:
    <Button cssClass="myclass" />
    
    .myclass {
      border-radius: 80;
    }
    

    是这样做的方法。但是,请注意当前存在一个错误,导致半径无法在某些设备上运行。见:https://github.com/NativeScript/NativeScript/issues/830

    圆形按钮示例:https://github.com/NativeScript/NativeScript/blob/master/apps/ui-tests-app/image-view/rounded-buttons.xml

    还有:

    在您的示例中,您正在编写 CSS。 NativeScript 应用程序样式的语言是不是 CSS,而是它自己的语言。然而,由于 CSS 是很多人都理解的东西,因此它非常大量借鉴了它。但这意味着例如:

    • 您可以使用大小定义,例如 pxem 等。NativeScript(以及几乎所有移动开发)中的大小格式是 DIPs,但您不能指定。因此你想写:border-radius: 80 而不是border-radius: 80px。这不是 CSS。
    • 你不能写像-webkit-border-radius: 80px; 这样的东西,它根本是无效的。 NativeScript“css”不会在 WebKit 浏览器中呈现,而是转换为 iOS/Android 可以理解的内容。

    【讨论】:

      猜你喜欢
      • 2017-10-26
      • 2019-12-03
      • 2016-01-13
      • 2017-12-05
      • 1970-01-01
      • 2021-10-01
      • 2018-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多