为什么这个包含水平线的视图标签会使应用程序崩溃?
Why does this view tag to include horizontal line crash the app?
当我注释掉视图标签时,应用程序运行正常。当它包含在内时它会崩溃。如果有人能帮助我,我会很高兴。
custom_info_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/background_marker"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/distance"
android:textColor="@color/foreground_marker"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/foreground_marker"
android:textSize="14sp" />
<TextView
android:id="@+id/snippet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/foreground_marker"
android:textSize="14sp" />
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/foreground_marker"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_custom_info_window" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:gravity="center"
android:paddingRight="8dp"
android:text="@string/custom_marker_remove"
android:textColor="@color/foreground_marker"
android:textSize="14sp"
android:textStyle="italic" />
</LinearLayout>
</LinearLayout>
android 监视器出错
12-28 00:28:10.580 22344-22344/com.example.nobodyme.buildingareafinder E/dalvikvm: Could not find class 'com.google.android.chimera.Activity', referenced from method lq.b
12-28 00:28:10.771 22344-22344/com.example.nobodyme.buildingareafinder E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.nobodyme.buildingareafinder, PID: 22344
android.view.InflateException: Binary XML file line #35: Error inflating class null
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.example.nobodyme.buildingareafinder.MapsActivity$CustomInfoWindowAdapter.<init>(MapsActivity.java:161)
at com.example.nobodyme.buildingareafinder.MapsActivity.onMapReady(MapsActivity.java:70)
at com.google.android.gms.maps.SupportMapFragment$zza.zza(Unknown Source)
at com.google.android.gms.maps.internal.zzt$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:361)
at aai.a(:com.google.android.gms.DynamiteModulesB:82)
at maps.ad.t.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.example.nobodyme.buildingareafinder.MapsActivity$CustomInfoWindowAdapter.<init>(MapsActivity.java:161)
at com.example.nobodyme.buildingareafinder.MapsActivity.onMapReady(MapsActivity.java:70)
at com.google.android.gms.maps.SupportMapFragment$zza.zza(Unknown Source)
at com.google.android.gms.maps.internal.zzt$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:361)
at aai.a(:com.google.android.gms.DynamiteModulesB:82)
at maps.ad.t.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
12-28 00:28:10.827 22344-22379/com.example.nobodyme.buildingareafinder E/NativeCrypto: ssl=0x633d2df0 cert_verify_callback x509_store_ctx=0x61e37940 arg=0x0
12-28 00:28:10.827 22344-22379/com.example.nobodyme.buildingareafinder E/NativeCrypto: ssl=0x633d2df0 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_ECDSA
还有什么方法可以添加水平线或如何解决这个问题?
您的标签必须是 View with capital letter 而不是 view。
希望对您有所帮助!
您的视图标签需要大写V
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/foreground_marker"/>
应该是
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/foreground_marker"/>
在您的堆栈跟踪中看到这一行:
android.view.InflateException: Binary XML file line #35: Error inflating class null
通常是你的 XML 文件有问题(不是你的 java 代码)
当我注释掉视图标签时,应用程序运行正常。当它包含在内时它会崩溃。如果有人能帮助我,我会很高兴。
custom_info_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/background_marker"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/distance"
android:textColor="@color/foreground_marker"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/foreground_marker"
android:textSize="14sp" />
<TextView
android:id="@+id/snippet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/foreground_marker"
android:textSize="14sp" />
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/foreground_marker"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_custom_info_window" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:gravity="center"
android:paddingRight="8dp"
android:text="@string/custom_marker_remove"
android:textColor="@color/foreground_marker"
android:textSize="14sp"
android:textStyle="italic" />
</LinearLayout>
</LinearLayout>
android 监视器出错
12-28 00:28:10.580 22344-22344/com.example.nobodyme.buildingareafinder E/dalvikvm: Could not find class 'com.google.android.chimera.Activity', referenced from method lq.b
12-28 00:28:10.771 22344-22344/com.example.nobodyme.buildingareafinder E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.nobodyme.buildingareafinder, PID: 22344
android.view.InflateException: Binary XML file line #35: Error inflating class null
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.example.nobodyme.buildingareafinder.MapsActivity$CustomInfoWindowAdapter.<init>(MapsActivity.java:161)
at com.example.nobodyme.buildingareafinder.MapsActivity.onMapReady(MapsActivity.java:70)
at com.google.android.gms.maps.SupportMapFragment$zza.zza(Unknown Source)
at com.google.android.gms.maps.internal.zzt$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:361)
at aai.a(:com.google.android.gms.DynamiteModulesB:82)
at maps.ad.t.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.example.nobodyme.buildingareafinder.MapsActivity$CustomInfoWindowAdapter.<init>(MapsActivity.java:161)
at com.example.nobodyme.buildingareafinder.MapsActivity.onMapReady(MapsActivity.java:70)
at com.google.android.gms.maps.SupportMapFragment$zza.zza(Unknown Source)
at com.google.android.gms.maps.internal.zzt$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:361)
at aai.a(:com.google.android.gms.DynamiteModulesB:82)
at maps.ad.t.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
12-28 00:28:10.827 22344-22379/com.example.nobodyme.buildingareafinder E/NativeCrypto: ssl=0x633d2df0 cert_verify_callback x509_store_ctx=0x61e37940 arg=0x0
12-28 00:28:10.827 22344-22379/com.example.nobodyme.buildingareafinder E/NativeCrypto: ssl=0x633d2df0 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_ECDSA
还有什么方法可以添加水平线或如何解决这个问题?
您的标签必须是 View with capital letter 而不是 view。 希望对您有所帮助!
您的视图标签需要大写V
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/foreground_marker"/>
应该是
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/foreground_marker"/>
在您的堆栈跟踪中看到这一行:
android.view.InflateException: Binary XML file line #35: Error inflating class null
通常是你的 XML 文件有问题(不是你的 java 代码)