代码之家  ›  专栏  ›  技术社区  ›  wendt88

Nativescript方形按钮不起作用

  •  0
  • wendt88  · 技术社区  · 7 年前

    我创建了一个带有angular的nativescript应用程序,其中有一些自定义样式的按钮,但我无法创建真正的正方形。

    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;

    或者可能有其他默认样式(阴影或其他)来设置较小的边界半径

    2 回复  |  直到 7 年前
        1
  •  0
  •   adinell    7 年前

        2
  •  0
  •   Gabriel Cséfalvay    6 年前

    对于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);