为什么此视图标记包含应用程序的水平线崩溃?

时间:2016-12-27 19:06:56

标签: android xml layout view horizontal-line

当我注释掉视图标记时,应用程序运行正常。当它被包括在内时它会崩溃。如果有人可以帮助我,我会很高兴。

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$1.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$5.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$1.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$5.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

如何添加水平线或如何修复此水平线?

2 个答案:

答案 0 :(得分:3)

您的视图标记需要有大写CASCADE

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"/>

通常mena的XML文件存在问题(不在您的java代码中)

答案 1 :(得分:2)

您的代码必须是大写字母而非查看。 希望它有所帮助!