代码之家  ›  专栏  ›  技术社区  ›  Pavan Vora

如何在Nativescript中为TabViewItem指定宽度?

  •  0
  • Pavan Vora  · 技术社区  · 6 年前

    enter image description here

    我想实现一些像上面那样的东西,其中相机选项卡的宽度比TabView中的其他选项卡小。

    0 回复  |  直到 6 年前
        1
  •  2
  •   Manoj    6 年前

    必须更新选项卡布局中包含相机的本机视图的宽度。下面的代码允许布局仅采用显示其中内容所需的宽度。

    const view = nativeTabView.getChildAt(i),
                    layoutParams = view.getLayoutParams();
    
                layoutParams.weight = 0;
                layoutParams.width = android.widget.LinearLayout.LayoutParams.WRAP_CONTENT;
                view.setLayoutParams(layoutParams);
    

    Playground Sample

    上面的示例是用NativeScript Core/TypeScript编写的,如果您是在Vue/Angular上实现的,那么不需要特别说明什么,只要使用适当的事件绑定语法,就可以了。