在Nativescript Camera中的自定义布局以及在android上根本看不到

时间:2019-03-08 10:10:41

标签: nativescript nativescript-telerik-ui nativescript-plugin

我正在使用nativescript-camera-plus进行自定义布局。我首先尝试了默认图标,但效果很好,但是当我在凸轮中放入自定义网格布局时,它是不可见的。

我在检查时已将所有图标都显示为false,但现在我只是放了一个通用代码来显示我面临的问题。

<Cam:CameraPlus id="camPlus" loaded="camLoaded" height="{{ cameraHeight }}" galleryPickerMode="multiple" enableVideo="true" confirmVideo="false" saveToGallery="true" showCaptureIcon="false" showGalleryIcon="false" showToggleIcon="false" showFlashIcon="false" confirmPhotos="true" flashOffIcon="icon" autoSquareCrop="true" insetButtons="true" insetButtonsPercent="0.02" imagesSelectedEvent="{{ imagesSelectedBinding }}" debug="true">
    <GridLayout rows="auto, *, auto" columns="auto, *, auto"><Button row="0" col="0" text="Flash" class="btn-transparent" tap="{{ toggleFlash }}" /><Button row="0" col="2" text="Camera" class="btn-transparent" tap="{{ toggleCamera }}" /><Image row="1" col="1" horizontalAlignment="center" verticalAlignment="center" src="https://img.clipartfest.com/4ec5e2315cea92482da5546e1e7fca89_-pinterest-cute-clipart-snowman-clipart-transparent-background_300-300.png" stretch="none" /><Button row="2" col="0" text="Gallery" class="btn-transparent" tap="{{ openGallery }}" /><Button row="2" col="2" text="Take" class="btn-transparent" tap="{{ takePic }}" /></GridLayout>
  </Cam:CameraPlus>

1 个答案:

答案 0 :(得分:0)

我想这是插件本身的错误。这是一种解决方法,

XML

<Cam:CameraPlus id="camPlus" loaded="camLoaded" height="{{ cameraHeight }}">
                <GridLayout id="overlay" rows="auto, *, auto" columns="auto, *, auto">
                    <Button row="0" col="0" text="Flash" class="btn-transparent" tap="{{ toggleFlash }}" />
                    <Button row="0" col="2" text="Camera" class="btn-transparent" tap="{{ toggleCamera }}" />
                    <Image row="1" col="1" horizontalAlignment="center" verticalAlignment="center" src="https://img.clipartfest.com/4ec5e2315cea92482da5546e1e7fca89_-pinterest-cute-clipart-snowman-clipart-transparent-background_300-300.png" stretch="none" />
                    <Button row="2" col="0" text="Gallery" class="btn-transparent" tap="{{ openGallery }}" />
                    <Button row="2" col="2" text="Take" class="btn-transparent" tap="{{ takePic }}" />
                </GridLayout>
            </Cam:CameraPlus>

JS

function camLoaded(args) {
    const parentView = args.object.nativeView;
    const overlayView = args.object.page.getViewById("overlay");
    parentView.removeView(overlayView.nativeView);
    overlayView.nativeView.setLayoutParams(new android.widget.RelativeLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams.FILL_PARENT, android.widget.RelativeLayout.LayoutParams.FILL_PARENT));
    parentView.addView(overlayView.nativeView);
}