그래서 카메라 피드를 사용하여 로그인 활동을 백그라운드로 만들려고합니다. https://developer.xamarin.com/guides/android/user_interface/textureview/에있는 예제를 테스트 해 보았습니다.하지만이 작업을 수행해야합니다.Xamarin - 배경으로 카메라 피드 설정
이protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
SetContentView(Resource.Layout.Login);
_textureView = this.FindViewById<TextureView>(Resource.Id.textureView);
_textureView.SurfaceTextureListener = this;
}
public void OnSurfaceTextureAvailable(
Android.Graphics.SurfaceTexture surface, int w, int h)
{
_cam = Camera.Open();
_textureView.LayoutParameters =
new FrameLayout.LayoutParams(w, h);
try
{
_cam.SetPreviewTexture(surface);
_cam.StartPreview();
}
catch (Java.IO.IOException ex)
{
Console.WriteLine(ex.Message);
}
}
axml 파일이 다소 다음과 같습니다 :
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextureView
android:id="@+id/textureView"
android:layout_width="match_parent"
android:layout_height="match_parent"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="SizeProportional" />
<LinearLayout
android:id="@+id/linearLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="SizeProportional">
<!-- Some other controls -->
</LinearLayout>
</AbsoluteLayout>
그러나 앱이 현재 처리되지 않은 예외를주는 OnSurfaceTextureAvailable 블록을 종료 한 후 충돌 그래서,이 시도. 예외를 깨고 작동하지 않습니다, 그것은 분명히 더 이상 실행되지 않는 스레드에 있습니다. 누군가가 왜 충돌하는지, 더 중요한 것은 그것을 고치는 방법을 알고 있습니까?
아, 간단하게 그 라인을 꺼내서 오류를 수정했고, 지금 의도 한대로 카메라 피드를 보여주고 있습니다. 많은 감사드립니다. 지금은 다른 문제가 있지만이 오류와 관련이 없으므로 다른 질문을하겠습니다. –