gpt4 book ai didi

android - 如何在 Nativescript 中设置按钮的边框半径?

转载 作者:行者123 更新时间:2023-12-02 12:18:32 24 4
gpt4 key购买 nike

我有一个按钮:

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

平台.android.css

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

但是border-radius不起作用。在Supported Properties写道 Native Script 支持 border-radius

最佳答案

<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 是很多人都理解的东西,因此它大量借鉴了 CSS。但这意味着例如:

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

关于android - 如何在 Nativescript 中设置按钮的边框半径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33951464/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com