我正在实现地图,并且使用了显示错误的github开关代码

时间:2019-10-08 14:20:00

标签: android github

我正在实现地图,并且使用了GitHub材质的动画开关,但是它显示了一些错误

我正在使用GitHub材质的动画开关,并尝试实现位置开关按钮。我已经在下面发布了XML文件,并且还记录了日志错误。它显示了材质动画开关不起作用。我的XML文件还在设计视图中显示未知片段的错误。

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".OperatorLocation">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:orientation="horizontal"
            android:weightSum="10"
            android:padding="16dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
                android:id="@+id/location_switch"
                android:layout_width="0dp"
                android:layout_weight="3"
                android:layout_height="wrap_content"
                app:icon_release="@drawable/ic_location_off"
                app:icon_press="@drawable/ic_location_on"
                app:base_release_color="@color/baseReleaseColor"
                app:base_press_color="@color/basePressColor"
                app:ball_release_color="@color/ballReleaseColor"
                app:ball_press_color="@android:color/white"/>

        </LinearLayout>

    </RelativeLayout>
</fragment>

日志详细信息如下:

com.eg.demo.whereismyparking E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.eg.demo.whereismyparking, PID: 10594
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eg.demo.whereismyparking/com.eg.demo.whereismyparking.OperatorLocation}: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:201)
    at android.app.ActivityThread.main(ActivityThread.java:6806)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
 Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
 Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
    at android.view.LayoutInflater.createView(LayoutInflater.java:651)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:867)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:870)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:870)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:420)
    at android.app.Activity.setContentView(Activity.java:2836)
    at com.eg.demo.whereismyparking.OperatorLocation.onCreate(OperatorLocation.java:74)
    at android.app.Activity.performCreate(Activity.java:7224)
    at android.app.Activity.performCreate(Activity.java:7213)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:201)
    at android.app.ActivityThread.main(ActivityThread.java:6806)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

 com.eg.demo.whereismyparking E/AndroidRuntime: Caused by: 
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:734)
    at com.github.glomadrian.materialanimatedswitch.painter.IconPainter.initBitmap(IconPainter.java:41)
    at com.github.glomadrian.materialanimatedswitch.painter.IconPainter.init(IconPainter.java:36)
    at com.github.glomadrian.materialanimatedswitch.painter.IconPainter.<init>(IconPainter.java:30)
    at com.github.glomadrian.materialanimatedswitch.painter.IconPressPainter.<init>(IconPressPainter.java:30)
    at com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch.initPainters(MaterialAnimatedSwitch.java:79)
    at com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch.init(MaterialAnimatedSwitch.java:65)
    at com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch.init(MaterialAnimatedSwitch.java:90)
    at com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch.<init>(MaterialAnimatedSwitch.java:54)

0 个答案:

没有答案