首页 文章

Nativescript方形按钮不起作用

提问于
浏览
0

我创建了一个带有角度的nativescript应用程序,其中我有一些自定义样式的按钮,但我无法创建它们真正的平方 .

我的css是:

Button {
    font-size: 13;
    color: #fff;
    padding: 20;
    text-transform: uppercase;
    background-color: #3c3d37;
    font-family: 'Oswald';
    letter-spacing: .2;
    border-radius: 0;
}
Button:highlighted {
    background-color: #494a43;
}

enter image description here

在该图像中,您可以看到一个小的边界半径,但为什么呢?如果我设置 border-radius: 10; ,它可以工作,我得到圆形边框,但似乎有一个最小边界半径> 0 .

或者是其他一些默认样式(阴影或其他东西),它设置的边界半径很小

2 回答

  • 0

    对于Android,您可以在NativeScript(而不是'with Nativescript')中替换视图的 backgroundDrawable 来实现此目的:

    var radius = myView.borderRadius.value; // this works only with px unit
    var color = myView.backgroundColor.android;
    
    var backgroundDrawable = new android.graphics.drawable.GradientDrawable();
    backgroundDrawable.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE);
    backgroundDrawable.setCornerRadius(radius);
    backgroundDrawable.setColor(color);
    
    myView.nativeView.setBackground(backgroundDrawable);
    
  • 0

    你不能使按钮与nativescript完美平方

相关问题