У меня проблема с TextureView, когда я выполняю операцию надувания для реализации camera2.
У меня проблема с Android 8, но она работает с samsung s5 Android 6.
Ошибка:
{Android.Views.InflateException: Binary XML file line #1: Error
inflating class md5773532591b176ca6c4550eebd08312bd.AutoFitTextureView
---> Java.Lang.Reflect.InvocationTargetException: Exception of type
'Java.Lang.Reflect.InvocationTargetException' was thrown. --->
Java.Lang.UnsupportedOperationException: TextureView doesn't support
displaying a background drawable
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
--- End of managed Android.Views.InflateException stack trace ---
android.view.InflateException: Binary XML file line #1: Error inflating
class md5773532591b176ca6c4550eebd08312bd.AutoFitTextureView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:658)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:877)
at
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at Camera2BasicFragment.n_onCreateView(Native Method)
at Camera2BasicFragment.onCreateView(Camera2BasicFragment.java:44)
at android.app.Fragment.performCreateView(Fragment.java:2626)
at
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1279)
at
android.app.FragmentManagerImpl.addAddedFragments
(FragmentManager.java:2422)
at android.app.FragmentManagerImpl.executeOpsTogether
(FragmentManager.java:2201)
at
android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute
(FragmentManager.java:2155)
at android.app.FragmentManagerImpl.execPendingActions
(FragmentManager.java:2056)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:719)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run
(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.UnsupportedOperationException:
TextureView doesn't support displaying a background drawable
at android.view.TextureView.setBackgroundDrawable(TextureView.java:321)
at android.view.View.setBackground(View.java:20532)
at android.view.View.<init>(View.java:5232)
at android.view.View.<init>(View.java:4647)
at android.view.View.<init>(View.java:4626)
at android.view.TextureView.<init>(TextureView.java:148)
at md5773532591b176ca6c4550eebd08312bd.AutoFitTextureView.<init> .
(AutoFitTextureView.java:29)
..
Это AutoFitTextureView.cs
public class AutoFitTextureView : TextureView
{
private int mRatioWidth = 0;
private int mRatioHeight = 0;........ link to pastebin
Код AutoFitTextureView
И это xml
<AutoFitTextureView
android:id="@+id/camera2_content"
android:layout_below="@id/header2_wrap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"/>........... link to pastebin
Код xml
Я называю xml в Camera2BaseFragment так:
public override View OnCreateView(LayoutInflater inflater, ViewGroup
container, Bundle savedInstanceState)
{
return inflater.Inflate(Resource.Layout.Camera2BasicFragment,
container, false);
}
Я пытаюсь удалить «AutoTextView» в xml, и инфляция работает.Как я могу решить проблему?Спасибо.